This question already has an answer here:
I am using a JavaScript Date
class & trying to get the current date using getDate()
method. But obviously it is loading system date & time. I am running the code from India but I want to get the date & time of UK using the same method. How can I do that ?
Date.getTimezoneOffset()
The getTimezoneOffset() method returns the time difference between Greenwich Mean Time (GMT) and local time, in minutes.
For example, If your time zone is GMT+2, -120 will be returned.
Note: This method is always used in conjunction with a Date object.
The
.getTimezoneOffset()
method should work. This will get the time between your time zone and GMT. You can then calculate to whatever you want.If you know the UTC offset then you can pass it and get the time using the following function:
Taken from: Convert Local Time to Another