### Convert UNIX Ticks

Example subs to convert a UNIX datetime to a string and v.v.
From UNIX to datetime multiply the UNIX value times 1000.
From datetime to UNIX divide by 1000.0D.
'Convert UNIX datetime ticks to datetime string
'Example:
'Log(ConvertUNIXTimeStamp(1445348164.10837, "dd-MM-YYYY"))
'Result: 20-10-2015 15:36:04
`Sub ConvertUNIXTimeStamp(dt As Long, dtf As String) As String
dt = dt * 1000
DateTime.DateFormat = dtf
Return $"${DateTime.Date(dt)} ${DateTime.Time(dt)}"$
End Sub`
'Convert datetime to UNIX ticks
'Example:
'Dim unixnow As Long = ConvertTimeStampToUNIX(DateTime.Now)
'Log(unixnow)
'Result: 1487924548
'which is 24-02-2017 09:22:28
`Sub ConvertTimeStampToUNIX(dt As Long) As Long
Return dt / 1000.0D
End Sub`

Changed: 2018-02-03 10:08, Category: DateTime, File: T6C183M1323.htm, ID: 1323