New to Kendo UI for VueStart a free 30-day trial

Represents a local date in a specified timezone.

The following example demonstrates how to convert a local date to the specified timezone.

Definition

Package:@progress/kendo-date-math

Syntax:

ts
import { ZonedDate } from '@progress/kendo-date-math';
import '@progress/kendo-date-math/tz/America/New_York';

const date = new Date('2018-03-13T00:00:00Z');
const tzDate = ZonedDate.fromLocalDate(date, 'America/New_York');

// If you run this example in GMT+0200,
// the output will be '2018-03-12T22:00:00.000Z'.
console.log(tzDate.toISOString());

The following example demonstrates how to convert between timezones.

ts
import { ZonedDate } from '@progress/kendo-date-math';
import '@progress/kendo-date-math/tz/America/New_York';
import '@progress/kendo-date-math/tz/America/Los_Angeles';

// Note the "Z" suffix for UTC dates.
const date = new Date('2018-03-12T22:00:00Z');

const tzDate = ZonedDate.fromLocalDate(date, 'America/New_York');
const result = tzDate.toTimezone('America/Los_Angeles');

// Regardless of the browser timezone
// the output will be '2018-03-12T15:00:00.000Z'.
console.log(tzDate.toUTCDate());

Properties

timezone

string

The ID of the timezone for this instance. For example, Europe/Sofia.

The timezone offset in minutes at the specified date and relative to UTC.

Accessors

Returns a cached local date that denotes the exact time in the set timezone.

Returns a cached Date instance with UTC date parts that are set to the local time in the set timezone.

Methods

Parameters:hint"default"Returns:

string

  • A primitive value.
Parameters:hint"string"Returns:

string

  • A primitive value.
Parameters:hint"number"Returns:

number

  • A primitive value.
Parameters:hintstringReturns:

string | number

  • A primitive value.

Adds the specified number of days and returns a new instance with the resulting date in the same timezone.

Parameters:daysnumber

The number of days that will be added.

Returns:

ZonedDate

ZonedDate - The resulting date.

Adds the specified number of milliseconds and returns a new instance with the resulting date in the same timezone.

The method compensates for DST transitions and ensures that the resulting date occurs exactly after the set amount of time in the timezone.

Parameters:millisecondsnumber

The number of days that will be added.

Returns:

ZonedDate

ZonedDate - The resulting date.

Returns a new instance that represents the same date.

Returns:

ZonedDate

Date - A copy of the instance of the current zoned date.

Converts an existing date to a specified timezone.

If the timezone parameter is omitted, the ZonedDate defaults to the timezone of the browser. This concept is known as "floating date" because it does not represent a particular moment in time. Instead, its actual value depends on the current timezone of the browser.

Parameters:dateDate

The local date that represents the actual time instance.

timezonestring

The ID of the timezone that will be assumed. For example, Europe/Sofia.

Returns:

ZonedDate

ZonedDate - The date in the specified timezone.

Creates a date in a specific timezone from the UTC date parts of the supplied Date.

If the timezone parameter is omitted, the ZonedDate defaults to the timezone of the browser. This concept is known as "floating date" because it does not represent a particular moment in time. Instead, its actual value depends on the current timezone of the browser.

Parameters:utcDateDatetimezonestring

The ID of the timezone that will be assumed. For example, Europe/Sofia.

Returns:

ZonedDate

ZonedDate - The date in the specified timezone.

Returns a new instance of the same zoned date having its time parts set to 00:00:00.000.

Returns:

ZonedDate

ZonedDate - The same date having its time parts set to 00:00:00.000.

Returns a local date that denotes the exact time in the set timezone.

Returns:

Date

Date - A local date that denotes the exact time in the set timezone.

Parameters:locales?string | string[]options?DateTimeFormatOptionsReturns:

string

  • A string.
Parameters:locales?string | string[]options?DateTimeFormatOptionsReturns:

string

  • A primitive value.
Parameters:locales?string | string[]options?DateTimeFormatOptionsReturns:

string

  • A primitive value.

Converts the date to the specified timezone.

Parameters:toTimezonestring

The timezone to which the values will be converted. For example, America/Los_Angeles.

Returns:

ZonedDate

ZonedDate - The resulting zoned date.

Returns a Date instance with UTC date parts that are set to the local time in the set timezone.

Returns:

Date

Date - A Date with UTC date parts that are set to the local time in the set timezone.