Home → Resources → Articles

How to Convert .NET DateTime to UNIX Timestamp

(Microsoft .NET) by Jason Skowronek on 07/26/2009
How to convert .NET DateTime to UNIX timestamp (as in PHP, etc.)
int timestamp = (DateTime.UtcNow - new DateTime(1970,1,1,0,0,0)).TotalSeconds
and convert a Unix timestamp to an ASP.NET DateTime value:
DateTime date = (new DateTime(1970,1,1,0,0,0)).AddSeconds(datestamp)

Comments (0)

Leave a comment
Name *
Email *
Homepage
Comment

Recommend

Nero Sale 150x150 

System Mechanic 

SkoNet provides comprehensive digital consulting services such as: web development, applications development, database design and architecture, business process management, customer relationship management, and many others that help businesses of every size, industry, and geography meet the complex challenge of managing and sharing information on the web. Our skills and expertise in online systems allow us to help customers build applications ranging from simple, single-page web sites to robust enterprise systems.

Online Backup, Ektron Consulting, Ektron Programmer, Ektron Developer, Ektron Partner Utah, Ektron Partner, Ektron Architect, Ektron Hosting, Salesforce.com Consultant Utah, Salesforce.com Partner Utah, Salesforce.com Partner, Salesforce.com Programmer, Salesforce.com Architect, Salesforce.com APEX Programmer