Moment.js: Date.now() javaScript analogue

Roman picture Roman · Apr 22, 2014 · Viewed 62.8k times · Source

Is there any simple way to get a number of milliseconds elapsed since 1 January 1970 00:00:00 UTC simular the Date.now() javaScript function?

Answer

Mike picture Mike · Apr 22, 2014

Use the valueOf method on a moment object:

For local time:

moment().valueOf();

For UTC:

moment().utc().valueOf();