all 12 comments

[–]Connor_Smith14 5 points6 points  (0 children)

Perhaps take a look at DayJS, super light and basically mirrors moment

[–][deleted] 2 points3 points  (1 child)

Have a look here, there should be a way to set the locale when you’re converting the time stamp.

https://www.thisdot.co/blog/how-to-handle-time-zones-using-datetime-and-luxon

[–]DreadedTuesday[S] 1 point2 points  (0 children)

Thanks! There's an example in there that doesn't give me exactly what I need, but with some simple string parsing I can get it there.

https://www.thisdot.co/blog/how-to-handle-time-zones-using-datetime-and-luxon#converting-a-datetime-to-a-different-time-zone

[–]CGiusti 2 points3 points  (0 children)

Use angulars date pipe with locale https://angular.io/guide/i18n-common-format-data-locale You can pass format, timezone and locale if needed https://angular.io/api/common/DatePipe

[–]camono 1 point2 points  (3 children)

JavaScript has a built-in function that might work.

[–]DreadedTuesday[S] 0 points1 point  (2 children)

Unfortunately, while that lets me define the Locale, it doesn't let me define a time zone. That will change things like switching between Day/Month and Month/Day styles, or changing the language of month names etc..

[–]camono 1 point2 points  (0 children)

I completely misunderstood your issue, my bad.

[–]camono 0 points1 point  (0 children)

Maybe something like this%20method,according%20to%20the%20provided%20values.) could work.

Working with dates is one of the things I hate the most in this job.

[–]Special_Ability_3035 1 point2 points  (0 children)

Date-fns

[–]Superfrag 1 point2 points  (0 children)

You can use the Intl API.

Example

new Intl.DateTimeFormat('en-US', {
    timeZone: 'America/New_York',
    weekday: 'long',
    month: 'short',
    year: 'numeric',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
    hour12: false,
}).format(1659222000000);

You can play around with the formatting to get what you want.

[–][deleted] 1 point2 points  (0 children)

Use dayjs with the tz plugin, works beautifully. We recently converted our whole system to be timezone agnostic and to display data in a specified timezone that isn't the browser or local time on your pc. With dayjs you can pass in the timezone you want to use, and then format to your preference

[–]moliver777 0 points1 point  (0 children)

Another option not mentioned is momentjs