我想弄清楚如何在不同的时区获取当前时间,但下面的方法不返回任何内容
var timeUpdate = setInterval(function () {
var currentTime = moment().format()
var GMT_current_time = currentTime.tz("Europe/London").format("HH:mm DD MMM");
$("#GMT_display_time").text(GMT_current_time);
}, 1000);
最佳答案
format
函数的输出是一个字符串。 tz
函数作用于 moment 对象。
moment().tz("Europe/London")
关于javascript - 使用 moment.js 获取不同时区的当前时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28131746/