I am building a mechanism to store information with the timestamp in a distributed system. Assuming that the information from all nodes in a distributed system will be merged together and sorted according to timestamp, how to make sure that all the timestamps from all systems refer to the same time_zone in Python?
From my research, time.time()
returns the time since Epoch
, but it might return different results depending on the platform:
Does Python's time.time() return a timestamp in UTC?
Another solution that comes to my mind is to use datetime.utcnow()
from datetime
package. If I use datetime.utcnow()
in all nodes, from my understanding all nodes will be using the same time_zone (UTC), hence the timestamps between all the nodes will be in sync. Can anyone confirm if I am correct in my logic?