Skip to content Skip to sidebar Skip to footer

Datetime To Timestamp Javascript

i have this time format : DateTime(2015, 5, 11, 12, 0, 0) i would like to know if i can convert it into a time stamp. i have made this convert function from ISO 8601 to Timestam

Solution 1:

did you try

Date.parse(your date here)/1000

Date.parse(new Date(2015, 5, 11, 12, 0, 0))/1000

Solution 2:

you can use the library momentjs to convert it.

Here you are assigning an instance of momentjs to CurrentDate:

var CurrentDate = moment();

Here just a string, the result from default formatting of a momentjs instance:

var CurrentDate = moment().format();

And here the number of seconds since january of... well, unix timestamp:

var CurrentDate = moment().unix();

momentjs guide

Post a Comment for "Datetime To Timestamp Javascript"