Is there anyway to set the global/default timezone in JS on the browsers side?
E.g. if I have some date that are +1300 and the user is -0800 it converts the times. But I always want to show the times as +1300.
My application is already very large so I'm hoping I can just set it in one place, otherwise it will involve going though hundreds of lines of code to adjust anywhere a date is used.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With