DateTime.TimeZoneBias

Syntax

TimeZoneBias: Integer;

Description

The TimeZoneBias property returns offset of the current time from the universal time coordinate (UTC).

Comments

The value is returned in minutes. Time zones that are ahead of UTC have negative offset; time zones that are behind UTC have positive offset. To get time value by UTC, add the obtained value of TimeZoneBias to the current time.

Example

Sub UserProc;
Var
    d, utc: DateTime;
    Culture: ICultureInfo;
Begin
    d := DateTime.Now;
    Culture := CultureInfo.Current;
    //Information about time zone
    Debug.WriteLine("Current time zone: " + DateTime.TimeZoneName);
    Debug.WriteLine("Offset from UTC: " + d.TimeZoneBias.ToString + " min");
    //Current time and UTC time
    Debug.WriteLine("Current time: " + Culture.FormatTime(d));
    utc := DateTime.AddMinutes(d, d.TimeZoneBias);
    Debug.WriteLine("UTC time: " + Culture.FormatTime(utc));
End Sub UserProc;

On executing the example the development environment console displays information about the current time zone (time zone name and UTC time offset), and also the current time and UTC time.

See also:

DateTime