【发布时间】:2013-07-04 03:00:03
【问题描述】:
我想在我的网页上使用此 JavaScript 代码显示 UTC 日期。
<script>
function myDate()
{
var now = new Date();
var d = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
var x = document.getElementById("demo");
x.innerHTML=d;
}
</script>
使用此代码,我将 UTC 日期显示为本地字符串,如下所示:“Thu Jul 04 2013 00:00:00 GMT+0530 (India Standard Time)”
我不想显示带有本地时间偏移 (GMT+0530 (IST)) 的字符串,而是希望时间显示为 UTC 字符串格式
【问题讨论】:
标签: javascript jquery momentjs