UFTimezone is a utility class to handle php timezones.

Hierarchy

  • UFTimezone

Constructors

Methods

  • Gets the date/time for a specific timezone from a date/time using the timezone of the server.

    Returns

    date/time for the timezone

    Parameters

    • aServerDate: Date

      Date using the server timezone

    • aPhpTimezone: string

      Timezone to convert to

    Returns Promise<Date>

  • Converts a date/time using the server timezone to a local time representation either using 24 hour or 12 hour format (using pm/am).

    Reference: https://en.wikipedia.org/wiki/12-hour_clock

    Returns

    a formatted time: H:mm [am|pm] or H::mm:ss [am|pm]

    Parameters

    • aServerDate: Date

      Date to convert

    • aPhpTimezone: string

      Timezone to convert to (this value is also used to determine 12 or 24 hour format)

    • anIncludeSeconds: boolean = false

      When true include seconds in value else only return hour and minutes.

    Returns Promise<string>

  • Gets the difference to UTC in seconds. The method uses caching and updates the offset after 1 hour.

    Returns

    difference to UTC in seconds.

    Parameters

    • aPhpTimezone: string

      A timezone using supported names in PHP

    Returns Promise<number>

  • Converts a date/time for a certain timezone to the date/time using the timezone of the server.

    Returns

    the date/time using the servers timezone.

    Parameters

    • aLocalDate: Date

      Date to convert

    • aPhpTimezone: string

      Timezone aDate is defined for

    Returns Promise<Date>

  • Converts a date/time for a certain timezone to the utc date/time.

    Returns

    the date/time using the utc timezone.

    Parameters

    • aLocalDate: Date

      Date to convert

    • aPhpTimezone: string

      Timezone aDate is defined for

    Returns Promise<Date>

  • Checks if the zone uses 24 hr formatting.

    Returns

    Parameters

    • aPhpTimezone: string

      A timezone using supported names in PHP

    Returns boolean

Generated using TypeDoc