Skip to content

Instantly share code, notes, and snippets.

@tianp
Created May 5, 2015 06:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tianp/06ca62659255b2f955a8 to your computer and use it in GitHub Desktop.
Save tianp/06ca62659255b2f955a8 to your computer and use it in GitHub Desktop.
Moment.js Get Today (24 hours) Timeframe Interval
var moment = require('moment')
// get this midnight and next moment object and convert into unix timestamp
// this midnight (1 minute after last midnight)
var thisMidnight = moment( moment().format('YYYY-MM-DD') + ' 00:01:00' ).unix()
// next midnight (1 minute before next midnight)
var nextMidnight = moment( moment().format('YYYY-MM-DD') + ' 23:59:00' ).unix()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment