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

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -