New to KendoReact? Start 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.
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');
console.log(tzDate.toISOString());
The following example demonstrates how to convert between timezones.
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';
const date = new Date('2018-03-12T22:00:00Z');
const tzDate = ZonedDate.fromLocalDate(date, 'America/New_York');
const result = tzDate.toTimezone('America/Los_Angeles');
console.log(tzDate.toUTCDate());
Name | Type | Default | Description |
---|
|
Date
|
|
|
Date
|
|
|
string
|
|
|
number
|
|
|
---|
|
Parameters | | |
---|
hint
|
"default"
|
|
|
|
|
---|
Adds the specified number of days and returns a new instance with the resulting date in the same timezone.
|
Parameters | | |
---|
days
|
number
|
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 | | |
---|
milliseconds
|
number
|
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.
import { ZonedDate } from '@progress/kendo-date-math';
import '@progress/kendo-date-math/tz/America/New_York';
const date = new Date('2018-03-13T00:00:00');
const tzDate = ZonedDate.fromLocalDate(date, 'America/New_York');
console.log(tzDate.toString());
console.log(tzDate.toISOString());
|
Parameters | | |
---|
date
|
Date
|
The local date that represents the actual time instance.
|
timezone
|
string
|
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.
import { ZonedDate } from '@progress/kendo-date-math';
import '@progress/kendo-date-math/tz/America/New_York';
const date = new Date('2018-03-12T18:00:00Z');
const tzDate = ZonedDate.fromUTCDate(date, 'America/New_York');
console.log(tzDate.toString());
console.log(tzDate.toISOString());
|
Parameters | | |
---|
utcDate
|
Date
|
|
timezone
|
string
|
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.
import { ZonedDate } from '@progress/kendo-date-math';
import '@progress/kendo-date-math/tz/America/New_York';
const date = new Date('2018-03-12T18:00:00Z');
const tzDate = ZonedDate.fromUTCDate(date, 'America/New_York');
console.log(tzDate.toLocalDate().toISOString());
console.log(tzDate.toLocalDate().toString())
|
Returns | |
---|
Date
|
Date - A local date that denotes the exact time in the set timezone.
|
|
|
---|
|
Parameters | | |
---|
locales?
|
string | string[]
|
|
options?
|
DateTimeFormatOptions
|
|
|
|
|
---|
|
Parameters | | |
---|
locales?
|
string | string[]
|
|
options?
|
DateTimeFormatOptions
|
|
|
|
|
---|
|
Parameters | | |
---|
locales?
|
string | string[]
|
|
options?
|
DateTimeFormatOptions
|
|
|
|
|
---|
Converts the date to the specified timezone.
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';
const date = new Date('2018-03-12T22:00:00Z');
const tzDate = ZonedDate.fromLocalDate(date, 'America/New_York');
const result = tzDate.toTimezone('America/Los_Angeles');
console.log(tzDate.toUTCDate());
|
Parameters | | |
---|
toTimezone
|
string
|
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.
import { ZonedDate } from '@progress/kendo-date-math';
import '@progress/kendo-date-math/tz/America/New_York';
const date = new Date('2018-03-12T18:00:00Z');
const tzDate = ZonedDate.fromUTCDate(date, 'America/New_York');
console.log(tzDate.toUTCDate());
|
Returns | |
---|
Date
|
Date - A Date with UTC date parts that are set to the local time in the set timezone.
|
|