SetTimeZone method

Official Content
This documentation is valid for:

This static method of DateTime data type allows replacing the CTZ with the one indicated in the parameter.


&bool = DateTime.SetTimeZone(<TimeZone>)

The <TimeZone> parameter must be of Timezones Domain type. This domain doesn’t list all possible Time Zone values. Therefore, if you need to use one that is not included in the domain, using TimeZones.Convert(<string>) is suggested; note that <string> is the Time Zone name.


Using this method, an application could offer a feature that shows data in a different TZ than the one automatically selected. For example, an SD application for managing meetings usually shows the time of a meeting in the TZ corresponding to the physical location in which it will take place. A user of the application may need to have this time shown in a different TZ to coordinate a video call during the meeting.

Important: This method has _no_ effect on the way data is stored in and/or retrieved from the database (read DateTime storage timezone property).

Changing the CTZ with this method affects the entire session until it is executed again.

Type returned

Boolean data type

  • True if the function was successfully executed.
  • False if the parameter value is not valid.


Event 'SetTZ'
   &bool= DateTime.SetTimeZone(Timezones.Azores)

Suppose that we’re running this application from a device in Uruguay. The TimeZone considered for all operations with DateTimes will be America/Montevideo. If, for example, a query is made by the TimeZone (with GetTimeZone method) we will obtain ‘America/Montevideo’.

However, after running the ‘SetTZ’ event shown in the example, the TimeZone for the entire application is changed to 'Atlantic/Azores' for all operations with DateTimes as from executing this event and until another SetTimeZone is executed.



Data types DateTime
Languages .NET, Java, Ruby

See also

Enabling TimeZone Support
DateTime storage timezone property
GetTimeZone method
FromTimeZone method
CurrentOffset method