0

Several questions and sites such as here and here mention that Python's getmtime returns UTC based on documentation (return os.path.getmtime(fileName)). However, I cannot find in the documentation for the function why this must be so. Why must it be so? I am worried it is dependent on the OS and I must rely on it being the same for Windows, Linux, and MacOS.

I am working in Python 3.6 and 3.8.

Steve
  • 3,957
  • 2
  • 26
  • 50

1 Answers1

1

anytime you see

The ... value is a floating point number giving the number of seconds since the epoch

that is by definition a utc timestamp since the epoch always refers to 1/1/1970 00:00 UTC

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
  • 2
    Although, the note in the `time` module may be worth considering: "**For Unix**, the epoch is January 1, 1970, 00:00:00 (UTC). **To find out what the epoch is on a given platform, look at time.gmtime(0)**." – Carcigenicate Aug 16 '21 at 20:08
  • 1
    @Carcigenicate on all3 OS listed it is always `1/1/1970 00:00 UTC` :) but yes i supose someone at somepoint in the future could buck this trend and break all softwares that depend on this fact – Joran Beasley Aug 16 '21 at 20:10