How can I convert a short date to a long date in Javascript? -


i need convert 04/06/13 (for example) long date - tue jun 04 2013 00:00:00 gmt+0100 (bst). how can using javascript? know how convert long date short date - not other way round.

you try parsing functionality of date constructor, result can stringify:

> new date("04/06/13").tostring() "sun apr 06 1913 00:00:00 gmt+0200" // or 

but parsing implementation-dependent, , there won't many engines interpret odd dd/mm/yy format correctly. if had used mm/dd/yyyy, recognized everywhere.

instead, want ensure how parsed, have , feed single parts constructor:

var parts = "04/06/13".split("/"),     date = new date(+parts[2]+2000, parts[1]-1, +parts[0]); console.log(date.tostring()); // tue jun 04 2013 00:00:00 gmt+0200 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -