I need to display the browser local time with time zone in the following format: '10 Feb 23 10:07:04 EST'
When I do this:
new Date(uploadDateTime).toLocaleString('en-US')
it displays for me in PST
02/10/2023, 10:07:04 AM (Pacific Standard Time)
but my colleague in India sees
02/10/2023, 10:07:04 AM (India Standard Time)
It displays wrong format and we need an abbreviation of time zone like PST, IST instead of (Pacific Standard Time). Also I should not hard code to 'en-US' so it works globally.
I've tried this way:
new Date(uploadDateTime).toLocaleString(undefined, { timeZoneName: 'short' })
In this case instead of 'en-US' if you put
undefined
it should default to browser's locale timezone.
Now I see
02/10/2023, 10:07:04 AM PST
But in India it shows:
02/10/2023, 10:07:04 GMT +5:30
How do I format the date so it shows in the following format in any part of the world?
10 Feb 23 10:07:04 EST