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
Post a Comment