Skip to content

parse

Parses the specified string and returns a DateTimeOffset object.

1
DateTimeOffset.parse(val: string):DateTimeOffset

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

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

Parameters

string val
    A string representing the date and time.

string format
    A format string that specifies the expected format of the input string.

Returns

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

Remarks

If the string does not include a time zone offset, the local time zone offset is used.

Example

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

Example

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

Example

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

See Also