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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -