I am given a date like these:
1555473600 1555560000
Is there a term for this type of date and how do I convert it to something like 12/28/2018 1:00 pm for example?
Thanks!
I am given a date like these:
1555473600 1555560000
Is there a term for this type of date and how do I convert it to something like 12/28/2018 1:00 pm for example?
Thanks!
DateTimeOffset provides methods to convert to/from values based on the Unix epoch (1st January 1970, midnight UTC).
var dateTime1 = DateTimeOffset.FromUnixTimeSeconds(1555473600);
var dateTime2 = DateTimeOffset.FromUnixTimeMillieconds(1555560000);
This looks to be a serial time, formatted in unix time. It is defined as the number of seconds since the unix epoch (January 1, 1970 midnight UTC).
Here is a hypothetical function for converting a unix time to human readable string.
private string epoch2string(int epoch) {
return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(epoch).ToShortDateString();
}
Now that you know what format that serial date is in, you can search the many posts discussing converting to/from unix time. Here is a useful link discussing unix time: