I am trying to obtain the time in other countries and using the moment timezone as below, I just wanted to check that I am doing this correct:
function showTheTime() {
var s = moment().tz("Europe/London").format("hh:mmA");
console.log("Time is: " + s);
}
function showTheTime() {
var s = moment().tz("Europe/Paris").format("hh:mmA");
console.log("Time is: " + s);
}
function showTheTime() {
var s = moment().tz("Europe/Madrid").format("hh:mmA");
console.log("Time is: " + s);
}
So this would work no matter what country the application is run from it would display the correct time.
Any help is appreciated.
Thanks
是的,您做对了,因为Moment给您提供了UTC时间,并且您正在使用TZ将其转换为特定区域。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.