Visual Basic Code Snippet - Returns current UNIX timestamp
(VB) Visual Basic code snippet to return current UNIX timestamp. UnixTimeNow() returns current UNIX timestamp.
Bookmark:
Visual Basic Code Snippet - Returns current UNIX timestamp
This Visual Basic code snippet returns current UNIX timestamp. This timestamp is a long integer containing the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.
Public Function UnixTimeNow() As Long Dim _TimeSpan As TimeSpan = DirectCast((DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)), TimeSpan) Return CLng(_TimeSpan.TotalSeconds) End Function
Visual Basic (VB) Keywords Used:
- TimeSpan
- DateTime
- UtcNow
- DirectCast
- TotalSeconds
Code Snippet Information:
- Applies To: .Net, VB, Visual Basic, Date/Time, Timestamp, Unix Time
- Programming Language : Visual Basic (VB)
External Resources: