1

I have a database file containing timestamp like "388740254860721408". Unfortunately, I don't have a lot of documentation for the format. So I'm not sure how the timestamp is formatted. How do I convert this number to a datetime?

  • 1
    Hard to say, if you don't know how the value originated. If it is "UNIX epoch" time, it is probably in nanoseconds. In which case you might check out this thread: https://stackoverflow.com/questions/249760/how-can-i-convert-a-unix-timestamp-to-datetime-and-vice-versa. And here is online convertor: https://www.epochconverter.com/ Basically you say that you don't know what the value is, so until you figure it out, you will probably not get an precise answer – Matyas May 24 '20 at 15:39

1 Answers1

0

Is this timestamp an actual value you found in the file? The first thing that came to mind is UNIX timestamp. Either in milliseconds or in seconds. For that big of a number I'd go with milliseconds, but It's invalid.

If in fact the UNIX milliseconds format is used to display this, the proper code for this is:

var time = DateTimeOffset.FromUnixTimeMilliseconds(yourValue);
Sotiris Panopoulos
  • 1,523
  • 1
  • 13
  • 18