Question:
I am making a request to one of server and getting response like this:In python, if I convert the current time into a timestamp, it looks like this:
Answer:
We know thatdatetime.now().strftime("%s%f")
is a timestamps measured in microseconds (since %s
is seconds and %f
is microseconds).And
1655375216687000
and 1655375242179881
are the same length, which suggests your source data is also a timestamp measured in microseconds. (The fact that the last three digits are always 000
suggests that it was originally derived from a source with milliseconds precision, but the value is clearly microseconds).We can use
datetime.fromtimestamp
: https://docs.python.org/3/library/datetime.html#datetime.datetime.fromtimestampHowever this expects a time in seconds, “as returned by
time.time()
“So we can:
datetime.datetime(2022, 6, 16, 11, 26, 56, 687000)
If you have better answer, please add a comment about this, thank you!