Skip to content

Add support for timezones #256

Description

@HenriBeck

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');
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions