jquery - JavaScript Date.toString() radix argument error -


why won't following code output date string!?

var d1 = date.parse('10/29/1990 12:00:00 am'); console.log(d1.tostring('dd/mm/yyyy')); 

the error is:

uncaught rangeerror: tostring() radix argument must between 2 , 36

just trying format date...

because d1 not date object, number. date.parse returns milliseconds representation, need feed new date or use date constructor directly.

and because javascript not have native date-formatting function, there implementation-dependent tostring , tolocalstring , standardized toisostring , toutcstring (though not supported in older ie). instead, have formatting manually getting single components , concatenating them. luckily, there's bunch of libaries that.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -