如何将日期(以毫秒为单位)转换为iso格式的javascript? [英] How to convert date in milliseconds to iso format javascript?

查看:84
本文介绍了如何将日期(以毫秒为单位)转换为iso格式的javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何在Javascript中输出ISO-8601格式的字符串?

如果我有一个表示日期的整数(以毫秒为单位),将其转换为iso格式的语法是什么?

If I have an integer that represents a date in milliseconds, what is the syntax to convert this to an iso format?

推荐答案

查看 日期 对象:

new Date(ms).toISOString()

请注意,此方法可能在旧版浏览器中不可用,但您可以< a href =https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString#Compatibility =noreferrer>为它们填充。

Notice that this method might not be available in older browsers, but you can shim it for them.

这篇关于如何将日期(以毫秒为单位)转换为iso格式的javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆