views:

81

answers:

3

Possible Duplicate:
How can I convert datetime microformat to local time in javascript?

Im writing up an ajax application where i have to interpret this date "2009-09-16T11:10:00" and output another string to something more readable.

+3  A: 

That's the ISO 8601 date format. There's an example here. If that doesn't suit your needs then a quick google search should help.

Seth
+3  A: 

No, there isn't a built-in function for doing that. You'd have to parse it yourself. Maybe something like this:

var s = "2009-09-16T11:10:00";
var tokens = s.split(/[\-T:]/);
var date = new Date(tokens[0], tokens[1] - 1, tokens[2],
    tokens[3], tokens[4], tokens[5], 0);

Then access the date string with:

alert(date.toString());
Ates Goral
Thanks for the custom and clean solution but dateJS seems to be a better solution for my project. thanks!
burnt1ce
+2  A: 

Try this js library: http://www.datejs.com

Pretty good and recognizes different date formats. You can also test your date right on the front page.

Andrey
This is exactly what i need. Thanks!
burnt1ce