-1

I need to show a UTC date time in the users browser as the users(browser) local time.

Ex. 04:52 UTC -> 09:52 PST (if browser/user is in Los Angeles)

as PST is -7 hours from UTC

I have no requirement, it can be done in Javascript, typescript, or using Luxon, which I currently use across my project.

chuckd
  • 13,460
  • 29
  • 152
  • 331
  • Have you come across this. Basically, you would like to convert a datetime stored in utc to a specific time zone --> https://www.thisdot.co/blog/how-to-handle-time-zones-using-datetime-and-luxon/ – Ross Bush Jul 29 '23 at 01:54
  • ya I saw that, but it assumes you know the time zone you want to set. I want to take a dateTime that's UTC and display it to the user in their times zone. Doesn't your browser know the time zone! So can't you set the UTC to the browsers time zone? Ex. If I'm in Los Angelas I set my UTC dateTime to -7 – chuckd Jul 29 '23 at 04:22
  • Do you have a complete date and time stamp, or only a time? – deceze Jul 29 '23 at 04:59
  • There are _many_ answers already here: https://stackoverflow.com/q/6525538/476 – deceze Jul 29 '23 at 05:00
  • I have both date and times. – chuckd Jul 29 '23 at 05:02
  • What are the odds that the example you provided has the exact same time as my example above??? – chuckd Jul 29 '23 at 05:04
  • Huh, waddaya know?! So, question answered? Should I refund your bounty? – deceze Jul 29 '23 at 05:14
  • if u want, if I can close or delete it I will. – chuckd Jul 29 '23 at 05:54
  • actually this link provided me the best solution for Angular - https://stackoverflow.com/a/53622231/1186050 – chuckd Jul 29 '23 at 05:58

1 Answers1

0

I found the best solution for me using Angular. Just add the 'Z'

{{(transfer.createdDate + 'Z' | date)}}

link is here

chuckd
  • 13,460
  • 29
  • 152
  • 331