Return to Snippet

Revision: 28415
at July 8, 2010 03:17 by acosonic


Initial Code
double timestamp = 1113211532;

// First make a System.DateTime equivalent to the UNIX Epoch.

System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);

// Add the number of seconds in UNIX timestamp to be converted.

dateTime = dateTime.AddSeconds(timestamp);

// The dateTime now contains the right date/time so to format the string,

// use the standard formatting methods of the DateTime object.

string printDate = dateTime.ToShortDateString() +" "+ dateTime.ToShortTimeString();

Initial URL


Initial Description


Initial Title
Proper c# timestamp to String

Initial Tags
date, c

Initial Language
C#