The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
This article is a very simple example of how to convert a UNIX timestamp to a
System.DateTime in Visual C#.
The UNIX timestamp
The UNIX timestamp represents the time measured in number of seconds since the Unix Epoch (1st of January 1970 00:00:00 GMT), and is well-known to PHP-developers.
How to convert UNIX timestamp to System.DateTime
Given below is an example of how to convert any given UNIX timestamp to a
double timestamp = 1113211532;
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
dateTime = dateTime.AddSeconds(timestamp);
string printDate = dateTime.ToShortDateString() +" "+ dateTime.ToShortTimeString();
How to convert System.DateTime to UNIX timestamp
I know that this part is just as essential as the above, but it seems that I am running out of time... I will of course return with an update on how to convert the
System.DateTime to a UNIX timestamp.
Any comments or suggestions are welcomed!
This is my first article on Visual C# ever, so bare with me...