Tools Links Login

Date Converter - 1 line of code

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

Original Author: unknown

Code

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

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 86 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.