-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
There is a libary called jstz to detect the browser's timezone and use moment.js and momenttimezone.js to format.
https://github.com/entraigas/jstz
const timezone = jstz.determine().name();
formatDate = (date, format) => {
const normalTimezone = moment.tz(date, 'Europe/Berlin');
const convertedDate = normalTimezone.clone().tz(timezone);
if (format)
return convertedDate.format(format);
// Maybe add support for us dates
else if (region === 'us')
return convertedDate.format('MM.DD.YYYY | HH:mm');
return convertedDate.format('DD.MM.YYYY | HH:mm');
};Metadata
Metadata
Assignees
Labels
No labels