Skip to content

Instantly share code, notes, and snippets.

@samkirton
Created October 19, 2017 15:53
Show Gist options
  • Save samkirton/bdec05118ff937dc0e9a1a59ab1d8cfc to your computer and use it in GitHub Desktop.
Save samkirton/bdec05118ff937dc0e9a1a59ab1d8cfc to your computer and use it in GitHub Desktop.

Revisions

  1. samkirton created this gist Oct 19, 2017.
    31 changes: 31 additions & 0 deletions nowDateOnly.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    Podcast.aggregate([
    {
    $project: {
    now: new Date()
    }
    },
    {
    $project: {
    nowDateOnly: {
    $subtract:[
    '$now', {
    $add: [
    {
    $multiply: [{$hour: "$now"},3600000]
    },
    {
    $multiply: [{$minute: "$now"},60000]
    },
    {
    $multiply: [{$second: "$now"},1000]
    },
    {
    $millisecond: "$now"
    }
    ]
    }
    ]
    }
    }
    },
    ]);