TimeZone

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from Object)


New in 2019r2

Used to identify a time zone in relationship to a Date.

Properties
Abbreviation fa-lock-32.png SecondsFromGMT fa-lock-32.png
Constructors

Constructor(gmtOffsetInSeconds As Integer)


Constructor(name As String)


Shared Methods
Current

Notes

Use any valid timezone. A list of common time zones is available here.

Sample Code

Creates a DateTime for Berlin timezone that matches the local timezone's hours and minutes:

Var d As DateTime = DateTime.Now(New TimeZone("Europe/Berlin"))

Convert a date in the local time zone to the GMT time zone:

Var date1 As DateTime = New DateTime(2021, 2, 1, 13, 0, 0, 0, TimeZone.Current)
Var gmt As New TimeZone(0) // Get GMT time zone
Var gmtDate As New DateTime(date1.SecondsFrom1970, gmt)

See Also

DateTime class