Thursday, 4 May 2017

Foreign Time to Local Time

I'm trying to convert foreign time to Local Time. I'm getting a date and time in Europe/London. Currently I'm using moment-timezone to get my code working, however its giving me a wrong output.

resultDate = new moment('2017-06-30T22:10:00').tz('Europe/London').format('YYYY-MM-DD HH:mm:ss');

I think the code thinks that the the date input is already in local time where I need to convert it into Europe/London which would give a local result, where as what I want is to actually convert the foreign time to local time.

In short the date and time as my input (2017-06-30T22:00:00), I am expecting it to be 7 hours in advance (2017-07-1T05:00:00) since I currently live in Asia/Manila, 7 hours in advance to London. However I'm getting 2017/06/30 15:00:00 +0100 as my result.

Is there a way for me to do this by utilizing the information 'Europe/London' or 'Asia/Manila' as seen in my code?



via Light

No comments:

Post a Comment