FromTimeZone method

Official Content
This documentation is valid for:

This method converts a DateTime value from one timezone, to another. The first one is passed as a parameter of the method, while the second one is the current timezone of the process executing the method.


&VarDateTimeInCurrentTimeZone = &VarDateTime.FromTimeZone(<TimeZone>)

The <TimeZone> ' parameter must be of type Timezones Domain.

Type Returned

A DateTime value resulting from the conversion of the original DateTime value, from the timezone specified in the parameter ( <TimeZone> ) to the current time zone of the process.

If the parameter value is not a valid time zone (that is, it doesn’t belong to the Time Zone domain values) then the method has no effect.


The current DateTime of the process depends on the application type. In case it is a web application, then it is defined by the browser that executed the application (Browser's Datetime). When this method is used from a Smart Devices Application, then the current DateTime of the process will be based off of the time of the mobile device running said application. Finally, when the process is running from a command line, then the current datetime is defined by the system's time (application server). In case the SetTimeZone method is executed, the current DateTime will be changed. Thus, after the call to the method, it may hold a different value from the browsers, mobile device, and system times, for web, smart devices, and command line processes, respectively. 


Event 'FromTZ'
    &ConvertedTimeZone = &VarDateTime.FromTimeZone(Timezones.Azores)

If we’re running this application from a device in Uruguay, then the current time zone of the process will be America/Montevideo ( UTC -03:00 ).

Suppose that the variable &VarDateTime contains the value 24/04/2013 16:00 and the event FromTZ is executed. As seen in the example above, the argument of the method is Timezones.Azores. This means that the function will attempt to convert the DateTime variable  &VarDateTime from the Azores time zone ( UTC -01:00 ) to the current timezone of the process, which is Montevideo. As a result, the variable &ConvertedTimeZone will take the value 24/04/2013 14:00.


Data types DateTime
Languages .NET, Java, Ruby

See also

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