Code python

Convert Timestamp to Milliseconds since Epoch in Python

Kontext Kontext visibility 3,127 comment 0 access_time 2 years ago language English

descriptionCode description

This code snippets provides different approaches to convert a Python timestamp object to an integer that denotes the total milliseconds since Epoch (midnight 1st Jan 1970 UTC, UNIX time).



*Your result can be different depends on the time when you run the code. The result is the same no matter if we use utcnow() or now() as they both represent the same time.

However, if your input timestamp format is string, you need to be careful about time zone information when converting them to timestamp, i.e. specify the right time zone accordingly. 

copyright This page is subject to Site terms.
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts