In Python, is epoch time returned by time() always measured from Jan 1, 1970?

后端 未结 5 1992
我寻月下人不归
我寻月下人不归 2020-12-20 14:12

Is the epoch start time in Python independent of the platform (i.e. always 1/1/1970)?

Or is it platform dependent?

I want to serialize datetimes (with second

5条回答
  •  醉酒成梦
    2020-12-20 14:46

    Epoch time (unix time) is a standard term:

    http://en.wikipedia.org/wiki/Unix_time

    Unix time, or POSIX time, is a system for describing instances in time, defined as the number of seconds that have elapsed since midnight Coordinated Universal Time (UTC), 1 January 1970,[note 1] not counting leap seconds.[note 2] It is used widely in Unix-like and many other operating systems and file formats. It is neither a linear representation of time nor a true representation of UTC.[note 3] Unix time may be checked on some Unix systems by typing date +%s on the command line

    That means if you use the epoch times through Python, it will be consistent across platforms. Your best bet for consistency is to use UTC in all cases.

提交回复
热议问题