Advertisement
2002ASP Math/ Dates #4297

Date Converter - 1 line of code

Converts a Date to Unix format. (e.i. the number of seconds since January 1, 1970.)

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public Function UnixDate(vDate As Date) As Long
 'Returns Unix Date (number of 
 '  seconds since Jan 1, 1970)
 '  Example: Text1.Text = UnixDate(Now)
 UnixDate = DateDiff("s", "1/1/1970 12:00:00 AM", vDate)
End Function
Public Function FromUnixDate(vUnixDate As Long) As Date
 'To Convert Back
 FromUnixDate = DateAdd("s", vUnixDate, "1/1/1970 12:00:00 AM")
End Function
Original Comments (3)
Recovered from Wayback Machine