title: In VBA, How to convert a UTC UNIX timestamp to Local timezone Date in a simple way?
body: <p>As I know, we can use below to roughly convert a UNIX timestamp to a VB Date</p>
  
  <p><em>CDate([UNIX timestamp]/ 60 / 60 / 24) + "1/1/1970"</em></p>
  
  <p>However, the time zone and daylight information are not considered.</p>
  
  <p>Time zone is not a big deal. But I cannot get the daylight bias information for a specific UNIX timestamp. </p>
  
  <p>Though, daylight bias of Date 1/1 is obviously different from Date 6/1, however, for Date 3/12 or Date 11/5, the daylight bias calculation is very complex.</p>
  
  <p>I tried several APIs, like “FileTimeToLocalFileTime” and “GetTimeZoneInformation” , but none of them work.</p>
  
  <p>Here is my code that can not handle daylight bias </p>
  
  <pre><code>Option Explicit
  
  #If VBA7 Then
    Private Declare PtrSafe Function LocalFileTimeToFileTime Lib "kernel32" (src@, tgt@) As Long
    Private Declare PtrSafe Function FileTimeToLocalFileTime Lib "kernel32" (src@, tgt@) As Long
  #Else
    Private Declare Function LocalFileTimeToFileTime Lib "kernel32" (src@, tgt@) As Long
    Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (src@, tgt@) As Long
  #End If
  
  Public Function ToUTC(ByVal datetime As Date) As Date
    Dim ftLoc@, ftUtc@
    ftLoc = (datetime - #1/1/1601#) * 86400000
    LocalFileTimeToFileTime ftLoc, ftUtc
    ToUTC = ftUtc / 86400000# + #1/1/1601#
  End Function
  
  Public Function FromUTC(ByVal datetime As Date) As Date
    Dim ftUtc@, ftLoc@
    ftUtc = (datetime - #1/1/1601#) * 86400000
    FileTimeToLocalFileTime ftUtc, ftLoc
    FromUTC = ftLoc / 86400000# + #1/1/1601#
  End Function
  
  Function getDateFromTimestamp(ByVal value) As Date
      Dim t1, t2
      t1 = CDate(value / 60 / 60 / 24) + "1/1/1970"
      t2 = FromUTC(t1)
      Debug.Print t2 - t1
      getDateFromTimestamp = t2
  End Function
  </code></pre>