Server side dates formatting

42 Views Asked by At

I have a nodejs server that I am sending messages from him. I want to format dates by the receiver localization data. If he is from US so the hour will be 2:00 pm and if he is from UK the hour will be 14:00. I have the user timezone.

1

There are 1 best solutions below

0
On

try using moment-timezone

import momentTimezone from "https://esm.sh/moment-timezone";
console.log(momentTimezone().tz("America/Los_Angeles").format())
console.log(momentTimezone().tz("Europe/London").format())