I have a unix timestamp for each cooment in my database. I want to output the user date and time depending on their location, or timezone.
How do I do that properly?
Think about how users get to the Internet today. You can't count on their location being accurate since they could be using a VPN, Tor or another system. Fix? Just add their timezone to their user profile.
Yes, but I want to get their timezone even if they were using a VPN, or whatever. Is there an effeciant way?
If they are using a VPN you usually get the TZ of where they appear according to the VPN. There's nothing wrong about that which is why my view is to let them set the TZ in their profile.
But if you insist, then use this call: Intl.DateTimeFormat().resolvedOptions().timeZone