Set Js Global Time Zone
Solution 1:
No. There is only one global timezone: UTC - unfortunately it's not the default in JS, you have to use the …UTC…
methods explicitly to get away from the user's local timezone.
You cannot set a timezone in JavaScript. Start with UTC and add/subtract hours if you want to display a custom timezone, like in this example.
it will involve going though hundreds of lines of code to adjust anywhere a date is used.
No. You only need to adjust the lines where a datetime is read or written. If the user does input dates according to his local timezone, you don't even need to fix that - only where you want to output it.
Solution 2:
JavaScript has a built in method to retrieve the timezone offset of the current machine:
var d = new Data();
var offset = d.getTimezoneOffset();
In the above example, offset would be the minutes offset from UTC to Local Time. If you know your own offset, you can write a global method to take theirs and run a conversion.
Post a Comment for "Set Js Global Time Zone"