javascript - new Date(..).getTime() is not equal to moment(..).valueOf() in momentJS? -


new date(..).gettime() should return timestamp in milliseconds. according documentation of momentjs expression moment(..).valueof() should same (return timestamp in milliseconds given date).

i checked following example data:

var timestampdate = new date("2015-03-25").gettime(); //timestamp in milliseconds? > 1427241600000 var timestampmoment = moment("03-25-2015", "mmddyyyy").valueof(); //timestamp in milliseconds? > 1427238000000 

as can see results not same.

now i'm searching function in momentjs returns me exact same data expression new date(..).gettime().

date constructor doc:

the utc time zone used interpret arguments in iso 8601 format not contain time zone information

moment constructor doc:

unless specify timezone offset, parsing string create date in current timezone

so specifying timezone in moment constructor results in same behavior date:

var timestampmoment = moment("03-25-2015 +0000", "mm-dd-yyyy z").valueof(); //> 1427241600000 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -