DateTime.Constructor(secondsFrom1970 as Double, timeZone as TimeZone = Nil)

From Xojo Documentation

Revision as of 18:28, 22 February 2021 by PLefebvre (talk | contribs) (Sample Code: Added time zone conversion code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Constructor

DateTime.Constructor(secondsFrom1970 As Double, timeZone As TimeZone)

Creates a date using number of seconds since 1 January 1970, 00:00 GMT. Use a negative value to specify a date before 1 January 1970.

Sample Code

This example creates the date April 1st, 1996 in the America/Chicago time zone:

Var d As New DateTime(828338400, New TimeZone("America/Chicago"))

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)