0

First of all this is my first time posting here so I'm really excited!

I recently got a task to decode a timestamp from one of our legacy systems, and I'm not sure what its encoding. From the binary data, it is printed by python as combination of characters in the '\x***' format.

These are two examples for timestamps taken in a 12 minute difference: \x00\xc2\xa8\x1a\\x0b\x02\x16r\x0c
\x00\xa0$\xb7\x00\x0c\x02\x16r\x0c

The actual timestamps are 1585842509 1585843216 respectively, and that's what I would like to get after decoding the strings above

Thanks you all in advance!

1 Answers1

0

Use datetime.datetime.fromtimestamp

import datetime

str = '\x00\xc2\xa8\x1a\\x0b\x02\x16r\x0c 1585842509'
print(datetime.datetime.fromtimestamp(int(str.split(' ')[1])))
Anton Pomieshchenko
  • 2,051
  • 2
  • 10
  • 24