Konvertieren Sie die Unix -VBA bis heute

Option Explicit
Const Unix1970 As Double = 25569 'CDbl(DateSerial(1970,1,1)
'' Test in immediate window
'' Print Date2Unix(Timer)
'' Print Unix2Date([paste result from above])

Public Function Date2Unix(ByVal vTimer As Date) As Double
'Always pass value as "Timer" more accurate than "Now" else use a date
    Date2Unix = Split((DateDiff("s", "01/01/1970", Date) + vTimer) * 1000, ".")(0)
End Function

Public Function Unix2Date(vUnixDate As Double) As Date
Dim epochDecimal
    epochDecimal = Left(vUnixDate, 10) & "." & Right(vUnixDate, 3)
    Unix2Date = Format((((epochDecimal / 60) / 60) / 24) + Unix1970, "m/d/yyyy h:nn:ss AM/PM")
End Function
lundeen-bryan