【发布时间】:2018-03-29 09:51:47
【问题描述】:
在我的 Angular 应用程序中,我有一个选择框,用户可以在其中选择他/她想要将特定时间转换到哪个时区。目前我正在使用momentjs进行日期时间操作,问题是我不知道如何动态更改日期时间的时区,因为momentjs只有.utc()方法。
到目前为止,我只使用了一个时区,所以我硬编码了utc() 方法。
我的服务:
public convertDate(): void {
this.date = moment(this.date).utc().format("DD/MM/YYYY - HH:mm");
}
应该是(伪代码):
public convertDate(selectedTimezone: string): void {
this.date = moment(this.date).selectedTimezone().format("DD/MM/YYYY - HH:mm");
}
【问题讨论】: