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

From Xojo Documentation

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

Constructor

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

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)