DayPilot.Date Constructor

The DayPilot.Date constructor creates a new immutable DayPilot date/time value from the current time, an ISO 8601 string, or a JavaScript Date object.

Declaration

new DayPilot.Date()
new DayPilot.Date(value)
new DayPilot.Date(date, isLocal)

Parameters

  • value (string) - date/time value in ISO 8601 format.

  • date (Date) - JavaScript object used to set the initial value. If it is null, the current local date and time are used.

  • isLocal (boolean) - if true, the date parameter is read as local time; if false, the GMT base of date is used.

Possible Values

  • "2035-01-01" - ISO 8601 date without time.

  • "2035-01-01T00:00:00" - ISO 8601 date/time without milliseconds.

  • "2035-01-01T00:00:00.000" - ISO 8601 date/time with milliseconds.

  • "2035-01-01T00:00:00Z" - ISO 8601 date/time with a UTC suffix.

  • "2035-01-01T00:00:00.000Z" - ISO 8601 date/time with milliseconds and a UTC suffix.

  • "2035-01-01T00:00:00+01:00" - ISO 8601 date/time with an offset suffix.

  • "2035-01-01T00:00:00.000+01:00" - ISO 8601 date/time with milliseconds and an offset suffix.

  • date (Date) - JavaScript Date object accepted by the overloaded constructor.

  • date - value read as local time when isLocal is true; otherwise the GMT base is used.

Notes

DayPilot.Date() creates a new instance using the current local date and time.

DayPilot.Date(value) creates a new instance using a date specified in ISO 8601 format such as "2035-01-01T00:00:00".

Accepted formats:

  • "2035-01-01"

  • "2035-01-01T00:00:00"

  • "2035-01-01T00:00:00.000"

  • "2035-01-01T00:00:00Z"

  • "2035-01-01T00:00:00.000Z"

  • "2035-01-01T00:00:00+01:00"

  • "2035-01-01T00:00:00.000+01:00"

DayPilot works with a single idealized timezone, so it is recommended to use date/time formats without explicit time zone information. See also Time Zones [doc.daypilot.org].

DayPilot.Date(date, isLocal) creates a new instance from a JavaScript Date object.

Example

const now = new DayPilot.Date();
const fromString = new DayPilot.Date("2035-01-01T00:00:00");
const fromDate = new DayPilot.Date(new Date(), true);

See Also

DayPilot.Date Class

Time Zones [doc.daypilot.org]

Client-Side Event API [doc.daypilot.org]

Availability

Availability of this API item in DayPilot editions:

LitePro
DayPilot for JavaScript