简体   繁体   English

ISO8601 DateTime字符串以本地用户时区显示

[英]ISO8601 DateTime String to be displayed in local users timezone

I have an ISO8601 datetime string retrieved from the server in UTC and would like to display it in the users local time in the following format. 我从UTC的服务器中检索了一个ISO8601 datetime字符串,并希望以以下格式在用户本地时间显示它。

YYYY/MM/DD - Hour:Mins:Seconds YYYY / MM / DD-小时:分钟:秒

How can I do this in javascript/jquery? 如何在javascript / jquery中做到这一点? Using momentjs is also acceptable. 也可以使用momentjs。

使用momentjs尝试以下代码片段

moment(dateISOFormat).format('YYYY/MM/DD - HH:mm:ss');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM