ASP.NET MVC - Display UTC time from server as local time on client side
2015-11-11 21:01
543 查看
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
<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
相关文章推荐
- WPF/ASP.NET:几个Prism中的术语
- Asp.Net网站部署-上传文件限制解决方案
- ASP.NET Web API 2基于令牌的身份验证
- asp.net微信开发第六篇----高级群发(文本)
- 【转】asp调用C#编写的DLL发送邮件
- ASP.net状态服务器使用
- ASP.NET MVC架构与实战系列之四:MVC实例演练
- ASP.NET MVC3 通过Url传多个参数方法
- asp.net处理json数据
- 对 ASP.NET 异步编程的一点理解
- ASP.NET MVC 中 ActionResult 和 ViewResult 在使用上的区别
- [Windows Server 2008] ASP.net安装方法
- asp程序无法上传5M以上的文件
- asp.net 获取客户端真实Ip
- 史上最全的ASP.NET MVC路由配置,以后RouteConfig再弄不懂神仙都难救你啦~ - Cherbim
- Metasploit概述
- Barcode Professional for ASP.NET使用教程:如何用System.Net.Mail 类创建条码图像的HTML邮件
- Barcode Professional for ASP.NET使用教程:如何用System.Net.Mail 类创建条码图像的HTML邮件
- asp.net新建表单保存和提交的问题解决方案
- asp.net mvc3.0 razor 网站全站脚本、样式统一引用解决放方案