Official Content

Replaces the Current TimeZone (CTZ) with the one indicated in the parameter.

Syntax

&boolean = DateTime.SetTimeZone(<TimeZone>)

Where:
   TimeZone
           Is a parameter that must be of Timezones Domains type. 

Note: 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; being <string> the Time Zone's name.

Data Type:
DateTime

Type returned:
Boolean

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

Scope

Generators: .NET.NET Framework, Java, Ruby (up to GeneXus X Evolution 3)

Description

By 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. However, an end-user may need to have this time shown in a different TZ, in order to be able to participate in the meeting. 

  • 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.

Samples

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

Suppose that this application is run 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), ‘America/Montevideo’ will be obtained.

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.

See Also

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

 


Last update: November 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant