Skip to content

parse

Parses the specified string and returns a DateTimeOffset object.

DateTimeOffset.parse(val: string):DateTimeOffset (DateTimeOffset)

Parses the given string in the specified format and returns a DateTimeOffset object.

DateTimeOffset.parse(val: string, format: string):DateTimeOffset (DateTimeOffset)

Parameters

string val
    A string representing the date and time.

string format
    A host-specific exact format. Server workflow scripts use a .NET invariant-culture format; browser form scripts use one of the application's supported date-format tokens.

Returns

A DateTimeOffset object representing the parsed date and time. A DateTimeOffset object representing the parsed date and time.

Remarks

When the input has no offset, the browser uses the user's offset and the server uses its local offset. Prefer an explicit Z or +/-HH:mm offset for values that cross users, tenants, or systems.

Parse a timestamp with an explicit offset

1
var dt1 = DateTimeOffset.parse("2012-01-01T00:00:00+03:00");

Parse a local timestamp without an offset

1
var dt2 = DateTimeOffset.parse("2012-01-01T00:00:00");

Parse a timestamp with a custom format string

1
var dt1 = DateTimeOffset.parse("2012-01-01T00:00:00+03:00", "yyyy-MM-ddTHH:mm:sszzz");

See Also