How to convert a value in UNIX type Timestamp to DateTime?

6

How to convert a value to type UNIX timestamp (seconds since 1970) , example 1396148400 , in a DateTime ?

    
asked by anonymous 13.04.2014 / 01:01

1 answer

5

A way to treat unix timestamp;

string start = "1396148900"; // o teu exemplo;
 // Criar equivalente Datetime > UNIX Epoch. (seconds since 1970)
 DateTime dtIni = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);

 // adicionar o nº de segundos  UNIX timestamp para comversão;
 dtIni = dateTime.AddSeconds(double.Parse(start));
    
13.04.2014 / 01:32