TimeZoneConvert

Converts a YmdHms datatime from one time zone to another.

Syntax:

TimeZoneConvert( datetime , from-timezone [, to-timezone])

Parameters:

(s) datetime  a datetime using the format YYYY:MM:DD:HH:MM:SS.

(s) from-timezone time zone ID (name) of datetime.

(s) to-timezone (optional) time zone ID (name) to convert datetime to (defaults to "local". See below.)

Returns:

(s) a time string in YmdHms format representing datetime in the "to" time zone.

 

Use this function to change a datetime from the "from-timezone" time zone to the corresponding datetime in the  "to-timezone" time zone. On Window 8/2012 and newer versions of Windows the function uses the datetime year to select the time offset in effect for that year.

Note 1: time zone IDs are usually recognizable time zone names. For example, a valid time zone ID is "Pacific Standard Time".

Both time zone parameters must be a time zone ID as recognized by the current Windows Operating System. Older Windows systems may not have the same IDs for the same time zone or even the same number of IDs as newer systems. You can use the TimeZoneList function to obtain the current system's time zone IDs in either an item list or an array, or a string containing the time zone ID of the current system.

The function accepts an empty string ("") or the text "local" in either time zone parameter to convert to or from the system's local time zone.

Note 2: you can use the time zone "UTC" to convert a datetime to or from Universal Coordinated Time.

Example:

; Convert from local time to Australian eastern time.
Now = TimeYmdHms()
AusieTime = TimeZoneConvert(Now, '', 'AUS Eastern Standard Time')
AusieFormated = TimeFormat(AusieTime, 'MMM d, yyyy h:m t')
Message('Current Eastern Aussie Time', AusieFormated)
; Convert back to local time.
LocalTime = TimeZoneConvert(AusieTime, 'AUS Eastern Standard Time')
LocalFormated = TimeFormat(LocalTime, 'MMM d, yyyy h:m t')
Message('Current Local Time', LocalFormated)
See Also:

TimeZoneList