How to Retrieve the Time Zone Information

This article discusses the use case of retrieving the time zone information at a certain location, at a given date.

Benefits

Time zone information is useful to be able to calculate the local time at a location.

Prerequisites

Concepts

The TimeZone information can be retrieved using the getTimeZone operation.
Given a certain location, the operation returns the offset to Coordinated Universal Time (UTC).
If a specific date is also set, the operation returns the daylight saving time information for that day, otherwise it returns this information for the current date.

Programming Guide

The sample below uses the RESTREST (Representational State Transfer) represents a World Wide Web paradigm, consisting of constraints to the design of components which results in a better performance and maintainability. API to request the time zone information of a location.

// Location var x = 6.1256572; var y = 49.4816576; // URL path shared by all used xServer layers var urlPath = xServerUrl + '/services/rest/XData/timeZone/' + x + '/' + y; // We use jQuery to send the request. Be sure to reference jQuery for this to work. $.ajax(urlPath).always(function(response) { // The request is expected to return a response of type TimeZoneResponse. if (response) { print('UTC offset is ' + response.timeZone.utcOffset + ' minutes (including daylight saving time of ' + response.timeZone.includedDaylightSavingTime + ' minutes)'); } else { print('Request did not succeed.'); } });

Related Topics

The following topics might be relevant for this use case.