how to parse milliseconds into date in javascript -
i getting stucked convert date ms (receiving json) recieving date in json in format below
/date(1355250600000)/
so converted ms --->
var d = response.contributionsdate.replace("/", "").replace("/", "").replace("date(", "").replace(")", "");
so d = 1355250600000
to convert tried code below--->
var date = new date(d); alert(date);
but did not work (invalid date
), if have idea date parsing, me
d
string, not number.
try
var date = new date(+d);
instead.
the prefix +
causes coercion number.
incidentally, can simplify replace operations to
var d = +response.contributionsdate.match(/^\/date\((\d+)\)\/$/)[0];
Comments
Post a Comment