How to get seconds since epoch (1/1/1970) in VBA?

27,633

Solution 1

How about:

datediff("s",#1970/1/1#,now())

Solution 2

This should run faster than the DateDiff solution:

Private Function Long2Date(lngDate As Long) As Date
    Long2Date = lngDate / 86400# + #1/1/1970#
End Function

Private Function Date2Long(dtmDate As Date) As Long
    Date2Long = (dtmDate - #1/1/1970#) * 86400
End Function
Share:
27,633
aF.
Author by

aF.

Last time I checked,                 I was me.

Updated on May 08, 2021

Comments

  • aF.
    aF. about 3 years

    How can I get seconds since epoch (1/1/1970) in VBA?