我想在我的网络应用程序中在同一时区工作,我尝试使用时区默认功能 moment.tz.setDefault("欧洲/马德里"); 日期转换(json 格式)不好,默认减去一天
这是我的小东西
http://plnkr.co/edit/xsugHtDLLUfxugCJRwIZ?p=preview
谢谢
var jsonDate = "/Date(118101600000)/"; // DD/MM/YY = 29/09/1973
alert(moment(jsonDate).format("DD/MM/YY")); // conversion ok
moment.tz.setDefault("Europe/Madrid");
alert(moment(jsonDate).tz('Europe/Madrid').format("DD/MM/YY")); // substract one day by default 28/09/1973
alert(moment(jsonDate).format("DD/MM/YY")); // substract one day by default 28/09/1973
最佳答案
@kaken
你能检查一下吗link
我点击该链接来解决时区问题。
例如:moment(jsonDate).zone("+03:00");//时刻可以解析JsonDate
要使用命名时区,请包含 Moment Timezone 并使用 .tz()
// determines the correct offset for America/Phoenix at the given moment
moment(1369266934311).tz('America/Phoenix').format('YYYY-MM-DD HH:mm')
// always "2013-05-22 16:55"
关于javascript - 时刻时区,设置默认时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29819652/