Skip to content

Add support for timezones #256

@HenriBeck

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

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