如何使用moment.js将UTC JSON日期时间转换为本地日期时间 [英] How to convert an UTC JSON date time to local date time using moment.js

查看:148
本文介绍了如何使用moment.js将UTC JSON日期时间转换为本地日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用moment.js将UTC JSON日期时间转换为:/ Date(1433309688000)/基于用户时区的本地日期时间。



json日期/日期(1433309688000)/印度标准时间的预期结果是2015-06-03 16:03:21。

解决方案

  var  tmp = moment(   / Date(1433309688000)/)。utcOffset('  + 10:29')。format('  YYYY-MM-DD HH:mm :SS' ); 
alert(tmp);





你也可以试试这个http://momentjs.com/timezone/[^]


How to convert an UTC JSON date time eg:/Date(1433309688000)/ to local date time based on user's timezone using moment.js.

The expected result for the json date /Date(1433309688000)/ in Indian Standard Time is 2015-06-03 16:03:21.

解决方案

var tmp =  moment("/Date(1433309688000)/").utcOffset('+10:29').format('YYYY-MM-DD HH:mm:ss');
alert(tmp);



you can try this http://momentjs.com/timezone/[^] too .


这篇关于如何使用moment.js将UTC JSON日期时间转换为本地日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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