Skip to content

Helper function to convert a Timezoned date to UTC Date #15

Description

@geferon

Currently supplying a Date to the constructor of UTCDate or to the function utc just creates a UTCDate object and sets the timezone offset property to 0, but it doesn't actually convert said time to UTC.
It would be useful if there would be a function that took said date, and not only created the UTCDate but also that it offset the time by it's timezone offset to actually convert it to UTC.
example:

export const toUtcDate = (date: Date) => new UTCDate(date.getTime() - date.getTimezoneOffset() * 60 * 1000);

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