converttolocaltime - script and chart function
Converts a UTC or GMT timestamp to local time as a dual value.
ConvertToLocalTime(timestamp [, place [, ignore_dst=false]])
Return data type: dual
|timestamp||The date to evaluate as a timestamp or expression resolving to a timestamp, to convert, for example '2012-10-12'.|
A place or timezone from the table of places and timezones below. Alternatively, you can use GMT or UTC to define the local time. The following values and time offset ranges are valid:
Information noteYou can only use standard time offsets. It's not possible to use an arbitrary time offset, for example, GMT-04:27.
|ignore_dst||Set to True if you want to ignore DST (daylight saving time).|
The resulting time is adjusted for daylight-saving time, unless ignore_dst is set to True.
Places and time zones
The ConvertToLocalTime function retrieves information on places and time zones around the world from the Windows registry. This means that for the function to work, the name of the place you want to use must match the corresponding name in the Windows registry.
The exact name with which a place is registered in the Windows registry may also change according to the language settings of your Windows installation. This is because the names of certain cities and countries are spelled differently in different languages.
There is a full list of places and time zones in the windows registry in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
Alternatively, you can find the list of time zones and places in Windows Control Panel. Open Control Panel, click on Date and Time settings and then Change time zone. You can see the full list of cities or countries associated with each time zone from the drop-down menu.
Examples and results:
|ConvertToLocalTime('2007-11-10 23:59:00','Paris')||Returns '2007-11-11 00:59:00' and the corresponding internal timestamp representation.|
|ConvertToLocalTime(UTC(), 'GMT-05:00')||Returns the time for the North American east coast, for example, New York.|
|ConvertToLocalTime(UTC(), 'GMT-05:00', True)||Returns the time for the North American east coast, for example, New York, without daylight-saving time adjustment.|
Using GMT offsets in combination with DST
Following the implementation of International Components for Unicode (ICU) libraries in QlikView November 2018, the use of GMT (Greenwich Mean Time) offsets in combination with DST (Daylight Saving Time) requires additional latitudinal information.
GMT is a longitudinal (east-west) offset, whereas DST is a latitudinal (north-south) offset. For example, Helsinki (Finland) and Johannesburg (South Africa) share the same GMT+02:00 offset, but they do not share the same DST offset. This means that, further to the GMT offset, any DST offset requires information on the latitudinal position of the local time zone (geographical time zone input) in order to have full information about local DST conditions.