C# Code Snippet - Returns current UNIX timestamp
(C-Sharp) C# code snippet to return current UNIX timestamp. UnixTimeNow() returns current UNIX timestamp.
Bookmark:
C# Code Snippet - Returns current UNIX timestamp
This C# 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 long UnixTimeNow() { TimeSpan _TimeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)); return (long)_TimeSpan.TotalSeconds; }
C# Keywords Used:
- TimeSpan
- DateTime
- UtcNow
- TotalSeconds
Code Snippet Information:
- Applies To: .Net, C#, Date/Time, Timestamp, Unix Time
- Programming Language : C#
External Resources: