开发者

Javascript convert date

Using JavaScript, how do I find the local date from a string like:

2010-12开发者_开发百科-29T03:32:17-0800

I expect the result to be something like

2010-12-29T12:32:17

(GMT +0100)

Best regards, Bob


You could try dateJs, which will parse the string for you:

Date.parse("2010-12-29T03:32:17-0800")

Timezone information is taken into consideration and you will get a date object in local time. You can also easily add or subtract hours from a date object manually.


You have date in the ISO 8601 format. To convert it to the Date you can use setISO8601 method which code you can find here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜