您的位置:首页 > 编程语言 > ASP

ASP.NET MVC - Display UTC time from server as local time on client side

2015-11-11 21:01 681 查看
View html:

<span class="utcdatetime">@user.MostRecentTestDate.Value.ToString("M/dd/yyyy hh:mm tt UTC")</span>
View js:
(needs reference to jquery.formatDateTime.js from https://github.com/agschwender/jquery.formatDateTime) $(".utcdatetime").each(function () {

var utcTime = $(this).html();
var localTime = $.formatDateTime('dd/mm/yy g:ii a', new Date(utcTime))
$(this).html(localTime);
});

参考:
http://stackoverflow.com/questions/6525538/convert-utc-date-time-to-local-date-time-using-javascript https://github.com/agschwender/jquery.formatDateTime
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: