Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Syntax
DateTimeZone.From(value as any, optional culture as nullable text) as nullable datetimezone
About
Creates a datetimezone from the given value.
value: The value used to create adatetimezone.culture: (Optional) The culture to use when transforming the value (for example, "en-US").
Values of the following types can be converted to a datetimezone value:
text: Returns adatetimezonevalue from textual representation. Refer to DateTimeZone.FromText for details.date: Returns adatetimezonewithvalueas the date component,12:00:00 AMas the time component, and the offset corresponding the local time zone.datetime: Returns adatetimezonewithvalueas the datetime and the offset corresponding the local time zone.datetimezone: Returnsvalue.time: Returns adatetimezonewith the date equivalent of the OLE Automation Date of0as the date component,valueas the time component, and the offset corresponding the local time zone. The OLE Automation Date consists of a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25. The base value is midnight, 30 December 1899. The minimum value is midnight, 1 January 0100. The maximum value is the last moment of 31 December 9999.number: Returns adatetimezonewith the datetime equivalent to the OLE Automation Date expressed byvalueand the offset corresponding the local time zone.null: Returnsnull.
If value is of any other type, an error is returned.
The value of the offset corresponding to the local time zone is different when running this function locally as opposed to running it online. When run locally, the local time zone is returned. When run online, the UTC time zone (+00:00) is returned.
Example 1
Convert the textual representation of a date, time, and timezone to a datetimezone value.
Usage
DateTimeZone.From("2020-10-30T01:30:00-08:00")
Output
#datetimezone(2020, 10, 30, 01, 30, 00, -8, 00)
Example 2
Convert the textual representation of Brazilian Portuguese date, time, and timezone to a datetimezone value.
Usage
DateTimeZone.From("13 de agosto de 2025 15:43:00 -03:00", "pt-BR")
Output
#datetimezone(2025, 08, 13, 15, 43, 00, -3, 00)
Example 3
Convert a number representing January 1, 2025 at 12 PM to a datetimezone value. The timezone in the result depends on whether the example is run locally or online.
Usage
DateTimeZone.From(45658.5)
Output
#datetimezone(2025, 01, 01, 12, 00, 00, 0, 00)