Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moment.js: Date.now() javaScript analogue

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?

like image 780
Roman Avatar asked Apr 22 '14 13:04

Roman


2 Answers

Use the valueOf method on a moment object:

For local time:

moment().valueOf(); 

For UTC:

moment().utc().valueOf(); 
like image 141
Mike Avatar answered Sep 28 '22 10:09

Mike


To get current date you may use the following line in your js file:

var currentDate = moment().format("DD-MM-YYYY"); 

It will show the date of the given format 19-Mar-2015

Click here to visit moment.js

like image 39
Abinash Pradhan Avatar answered Sep 28 '22 08:09

Abinash Pradhan