Unix Epoch conversion

gbanks

Registered User.
Local time
Today, 12:51
Joined
Feb 9, 2000
Messages
161
This is really odd. If you can figure this out consider yourself awesome.

I'm trying in access 2000 to convert a unix epoch date to a regular readable date format. Example: 1037915399 = unix date value this value is how many seconds the record was created since Jan. 1, 1970. I need to figure what is the date representation for the example. If you figure this out can you show me how? Anybody ever do this before? I'm clueless.. Thanks...
 
Try this:

Public Function DateFromSeconds(UnixDateValue As Long) As Date
Dim days As Long
Dim hr As Long
Dim min As Long
Dim sec As Long

days = UnixDateValue \ 86400
UnixDateValue = UnixDateValue - days * 86400

hr = UnixDateValue \ 3600
UnixDateValue = UnixDateValue - hr * 3600

min = UnixDateValue \ 60
UnixDateValue = UnixDateValue - min * 60

sec = UnixDateValue

DateFromSeconds = DateSerial(1970, 1, 1 + days) + TimeSerial(12 + hr, min, sec)
End Function

HTH,
 

Users who are viewing this thread

Back
Top Bottom