Reputation: 147
Good day! Faced with the problem. Need to convert the date. In the database it is stored in the format:
1332622254
1332622368
1332622467
1332622551
I am with this format never encountered. What is this format, I do not know. Help to format it in vfeueshu. Thanks in advance.
Upvotes: 0
Views: 97
Reputation: 39255
It's a time in seconds since midnight 1-1-1970:
var epoch = new DateTime(1970,1,1);
var ts = TimeSpan.FromSeconds(1332622254);
var date = epoch.Add(ts);
date
is then 24-3-2012 20:50:54
EDIT
Or simpler, as MarcinJuraszek rightly stated:
var epoch = new DateTime(1970,1,1);
var date = epoch.AddSeconds(1332622254);
Note that this might be a date/time in UTC, so maybe you will have to adjust for your timezone.
Upvotes: 1