title: Convert ISO date to UNIX timestamp mongodb
body: <p>There are hundreds of threads and operators to get date objects into ISO strings but can't find any resources on doing it the other way around as part of the mongoose/mongodb aggregation operators in Node.</p>
  
  <p>I have a legacy mongodb 3.6 that's currently being used in production and I have a pipeline where I'm trying to convert a normal ISO date object from mongo into an UNIX timestamp so I can use it together with ngx-charts and other charts.</p>
  
  <p>I can't use the $toDate, $convert operator or $dateFromString as the options that I need are not available in 3.6</p>
  
  <p>So far I have tried variations of this: </p>
  
  <pre><code>      $project: {
          _id: 0,
          // name: '$_id._id',
          value: '$_id.count',
          name: new Date.parse('$_id.date').getTime(),
          min: '$min',
          max: '$max'
        }
  </code></pre>
  
  <p>but none of that worked as the aggregation is processed on the db and has no idea what that function is. I've looked at many operators and tried to convert to string first and then back to UNIX date but it doesn't seem to have anything available to convert into javascript/unix timestamp from that ISO date.</p>