How to convert Date in angular to another time zone

本小妞迷上赌 提交于 2020-06-26 04:26:06

问题


I am using Date() to get the current time in local time zone. And I have formatted that as follows:

this.today = new Date();
      from = new DatePipe('en-Us').transform(this.today, 'dd:MM:yyyy hh-mm-ss');

Now I want to convert the from date time to Europe/London time zone. How Can I do this without moment. Please help me


回答1:


I solved my issue by adding an another parameter for timezone according to https://angular.io/api/common/DatePipe

Here is the update code:

to = new DatePipe('en-Us').transform(this.today, 'dd:MM:yyyy hh-mm-ss', 'GMT+1');


来源:https://stackoverflow.com/questions/52417335/how-to-convert-date-in-angular-to-another-time-zone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!