我有以下已填充的时区列表,用户可以选择示例
{name: '(UTC-12:00) International Date Line West', offset: '-12:00:00'}
{name: '(UTC-11:00) Coordinated Universal Time-11', offset: '-11:00:00'}
{name: '(UTC-10:00) Aleutian Islands', offset: '-10:00:00'}
{name: '(UTC-06:00) Guadalajara, Mexico City, Monterrey', offset: '-06:00:00'}
{name: '(UTC-06:00) Saskatchewan', offset: '-06:00:00'}当用户选择一个时区时,如何获得他们选择的区域的实际时间和日期?
我可以得到以下当地时间:
var today = Moment();
this.date = today.format("dddd,D MMM YYYY");
this.times = Moment().format("HH:mm:ss");但我不知道如何得到不同地点的时区。例如,如果他们选择了(UTC-12:00)国际日期线西,我如何显示该位置的日期和时间?
发布于 2022-03-15 16:29:25
既然您正在使用moment-timezone.js
Docs的示例:
let moment = require('moment-timezone');
moment().tz("America/Los_Angeles").format();https://stackoverflow.com/questions/71485566
复制相似问题