I am trying to convert an ISO date to EST, so that the user always sees EST, regardless of the system.
Like so
luxon.DateTime("2023-04-16T03:00:00Z").setZone("EST").toFormat('ttt')
Yet it always comes out like so:
10:00:00 PM GMT-5
I want:
10:00:00 PM EST
What am I doing wrong? I know EST is IANA compliant.
It seems like Luxon is displaying the offset and abbreviation instead of just the abbreviation for the time zone. To achieve your desired format, you can use the toFormat function with a custom format string. Here’s an example:
toFormat
luxon.DateTime.fromISO("2023-04-16T03:00:00Z") .setZone("America/New_York") // Use the IANA time zone identifier for EST .toFormat('hh:mm:ss a z');
In this example:
hh:mm:ss a
z
This should give you the output you’re looking for:
Make sure to replace "America/New_York" with the correct IANA time zone identifier for the Eastern Standard Time (EST) zone. Luxon relies on the IANA time zone database for accurate time zone information.
"America/New_York"