本文介绍了使用Javascript将iso时间戳转换为日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个很简单的问题,但我似乎无法得到答案。如何转换iso时间戳以使用JavaScript显示日期/时间?

This seems like a pretty simple question but I can't seem to get an answer for it. How can I convert an iso timestamp to display the date/time using JavaScript?

示例时间戳:2012-04-15T18:06:08-07:00

Example timestamp: 2012-04-15T18:06:08-07:00

任何帮助都不胜感激,Google失败了。谢谢。

Any help is appreciated, Google is failing me. Thank you.

推荐答案

将其传递给Date构造函数。

Pass it to the Date constructor.

> var date = new Date('2012-04-15T18:06:08-07:00')
> date
  Mon Apr 16 2012 04:06:08 GMT+0300 (EEST)

有关Date的更多信息,请查看。

For more information about Date, check https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date.

这篇关于使用Javascript将iso时间戳转换为日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 04:56