• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

.NET and unix timestamps

Gaunt

Senior member
Does anyone know of a way to handle unix timestamps (ie, number of second since Jan 1, 1970) in .NET (Using C#, for reference)? I need to be able to read in the number of seconds, and get the corresponding Month, Day, Year, and time out of it.

The closest I can come is the Ticks property of System.DateTime, which seems to provide support for 100-nanosecond increments since Jan 1, 0001, which should be usable, with some conversions.

Any suggestions?
 
Simplest solution seems to be creating a System.DateTime object, initialized to Jan 1, 1970, and then using the AddTicks() method of DateTime to add the number of seconds in the unix timestamp you are attempting to convert, multiplied by 10000000, which according to the DateTime object, is the number of Ticks Per Second.

Just thought I'd post incase anybody else was curious...
 
Back
Top