开发者

Format javascript date to match rails format

I get a date back from rails that looks like: "2010-10-29T00:00:00+00:00"

And I'd like to con开发者_如何学JAVAvert a javascript date created by 'new Date()' to that format. Is there an easy way?


You're looking for ISO 8601 format.

I've always been fond of the Date.js Library for any date manipulation/formatting in JS.

you can use the the toISOString() method to get this format


using dateformat you can format date as you want

TRY these

http://blog.stevenlevithan.com/archives/date-time-format

http://jacwright.com/projects/javascript/date_format

http://www.mattkruse.com/javascript/date/


Looks like you're trying to parse an ISO8601 date string. A quick google search returned a function at dansnetwork.com that claims to be able to parse ISO8601 strings into Date objects. Or you could try parsing it yourself (Check out String.split(), and the Date api.). Luckily for you, I believe I read somewhere that Mozilla's Javascript 1.8.5 is going to support ISO8601 strings in its native parse() function. Hopefully the rest will follow suit shortly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜