Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 3
    This answer is also a little bit wrong. getmtime is the nearest thing available on Unix (where getting creation dates isn't possible), but is definitely not the best function to use on Windows, where the ctime is a creation time. Commented Sep 12, 2016 at 20:00
  • 7
    @MarkAmery - This answer is clearly labeled as just being about modification time. Commented Jan 19, 2017 at 18:30
  • 4
    I strongly recommend using datetime.datetime.fromtimestamp(t, tz=datetime.timezone.utc) here, as the naive datetime object returned otherwise has a tendency to be interpreted as being in the local timezone instead while Unix timestamps are always relative to the 01.01.1970 00:00 UTC. Commented Jan 26, 2022 at 18:29