Username:   Password:  

UNIX timestamp

public static int UnixTimestamp()
{
    DateTime time = new DateTime(0x7b2, 1, 1);
    DateTime now = DateTime.Now;
    TimeSpan span = new TimeSpan(now.Ticks - time.Ticks);
    TimeSpan span2 = new TimeSpan(DateTime.UtcNow.Ticks - DateTime.Now.Ticks);
    return Convert.ToInt32((double) (span.TotalSeconds + span2.TotalSeconds));
}

Function for getting the current UNIX timestamp on a windows based machine.

Tags

C# Sharp time unix