Skip to content

constructor

Creates a value for the current local date, time, and offset.

new DateTimeOffset(): DateTimeOffset (DateTimeOffset)

Creates a new value from a JavaScript Date.

new DateTimeOffset(val: Date): DateTimeOffset (DateTimeOffset)

Creates a value from milliseconds since the Unix epoch in the browser's local time zone.

new DateTimeOffset(val: number): DateTimeOffset (DateTimeOffset)

Creates a value from an ISO-like or locale-formatted string.

new DateTimeOffset(val: string): DateTimeOffset (DateTimeOffset)

Creates a new value from calendar components in the current local offset.

new DateTimeOffset(year: number, month: number, day: number): DateTimeOffset (DateTimeOffset)

Creates a new value from local calendar and time components.

new DateTimeOffset(year: number, month: number, day: number, hour: number, minute?: number, second?: number, millisecond?: number): DateTimeOffset (DateTimeOffset)

Parameters

Date val
    A JavaScript Date object.

number year
    The year (e.g., 2024).

number month
    The month (1-12, where 1 is January).

number day
    The day of the month (1-31).

number hour
    The hour (0-23).

number minute optional
    The minute (0-59).

number second optional
    The second (0-59).

number millisecond optional
    The millisecond (0-999).

Remarks

Supported by both browser form scripts and server workflow scripts.

Example

1
var dt1 = new DateTimeOffset(new Date());
This overload is implemented by browser form scripts. Server workflow scripts should use numeric components or parse. Browser form scripts only. In server workflow scripts, use calendar components or parse. Browser form scripts only. In server workflow scripts, use parse.

Example

1
var dt1 = new DateTimeOffset(2012, 1, 1);
Server workflow scripts only. Browser form scripts do not implement component-based constructors; use DateTimeOffset.parse with an explicit offset. Server workflow scripts only. Browser form scripts do not implement component-based constructors; use DateTimeOffset.parse with an explicit offset.

See Also