Converting a HEX value to a DateTime
-
Hi. I guess you all know about PE files' timestamps. The are in hex, and for example 41DE6BF7 means 07/01/2005 11:01:11. I tried many ways to 'convert' the timestamp to a DateTime object, but they all failed. (DateTime.FromFileTime(...), FromTicks(...) My question is, how to 'convert' the hex value to a DateTime. Thanks in advance and best regards, Stan
-
Hi. I guess you all know about PE files' timestamps. The are in hex, and for example 41DE6BF7 means 07/01/2005 11:01:11. I tried many ways to 'convert' the timestamp to a DateTime object, but they all failed. (DateTime.FromFileTime(...), FromTicks(...) My question is, how to 'convert' the hex value to a DateTime. Thanks in advance and best regards, Stan
No, timestamps are not in hex. Hexadecimal is only a numeric representation. They're a number and that's all. To actually be stored in hex would require storing a string, which I know is now the case. To convert numbers to a filetime, you can pass the number (a
long
, orInt64
) to either of the staticDateTime.FromFileTime
orDateTime.FromFileTimeUtc
methods. In your case, you'll want to useDateTime.FromFileTimeUtc
since timestamps are specified in UTC (+0 GMT). This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]