In Javascript, the date object does not store any specific timezone value. The time is stored in the value of the local timezone relative to GMT(Greenwich Mean Time). If we print the time object, we can see that the time is represented as a value with a sign and offset from the UTC(Coordinated Universal Time) or GMT. Both UTC and GMT are similar values differing in a range of milliseconds.
new Date()
Output: Thu Mar 30 2023 16:00:14 GMT+0530 (India Standard Time)
If we try to create a date object for a different timezone only using the time values, the result will be another date object in the local timezone.
new Date(’03-30-2022, 0:00:00 AM’)
Output: Wed Mar 30 2022 00:00:00 GMT+0530 (India Standard Time).
We can specify the timezone offset value in the string argument passed to the date object to create a date object at a different timezone. Anyway, the date object will be still represented in the local timezone.
new Date(’03-30-2022, 0:00:00 AM GMT+1′)
Output: Wed Mar 30 2022 04:30:00 GMT+0530 (India Standard Time)
If you want to show a date as a string in exact time values of another timezone, use the ‘Intl’ object to convert the time value. Make sure the framework you are using supports the ‘Intl’ object.
new Intl.DateTimeFormat(‘en-GB’, { dateStyle: ‘full’, timeStyle: ‘long’, timeZone: ‘America/Los_Angeles’ }).format(new Date());
Output: Sunday, 12 March 2023 at 14:00:00 GMT-7
The ‘dateStyle’ and ‘timeStyle’ variables can take values: “full”, “long”, “medium”, “short” and undefined.
For finding the standard timezone names, refer to this: Standard timezone names