Posted By

acosonic on 07/08/10


Tagged

display date c timestamp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Proper c# timestamp to String


 / Published in: C#
 

  1. double timestamp = 1113211532;
  2.  
  3. // First make a System.DateTime equivalent to the UNIX Epoch.
  4.  
  5. System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
  6.  
  7. // Add the number of seconds in UNIX timestamp to be converted.
  8.  
  9. dateTime = dateTime.AddSeconds(timestamp);
  10.  
  11. // The dateTime now contains the right date/time so to format the string,
  12.  
  13. // use the standard formatting methods of the DateTime object.
  14.  
  15. string printDate = dateTime.ToShortDateString() +" "+ dateTime.ToShortTimeString();

Report this snippet  

You need to login to post a comment.