parse¶
Parses the specified string and returns a DateTimeOffset object.
1 | |
Parses the given string in the specified format and returns a DateTimeOffset object.
1 | |
Parameters¶
string val
A string representing the date and time.
string format
The exact format: o, d, g, G, or a custom format with the parts listed in DateTimeOffset.toString.
Returns¶
A DateTimeOffset object representing the parsed date and time.
Remarks¶
When the input has no offset, the local offset is used: the user's in browser form scripts and the server's in server workflow scripts. Prefer an explicit Z or +/-HH:mm offset for values that cross users, tenants, or systems. Text that is not ISO 8601 is read with the culture: the invariant culture in server workflow scripts, and the user's language in browser form scripts.
When the text is not a valid date, server workflow scripts throw an error, and browser form scripts return null for compatibility with existing forms. Use DateTimeOffset.tryParse when the same code runs on both sides.
Without zzz in the format, the local offset is used.
Examples¶
Parse a timestamp with an explicit offset¶
1 | |
Parse a local timestamp without an offset¶
1 | |
Parse a timestamp with a custom format string¶
1 | |