Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Get The Created Or Modified Timestamp For A File In Python

TODO: Add note about creating and modified times and how they intermix.

Code

import os

file_path = "/Users/alan/Desktop/example.txt"

modified_time = os.path.getmtime(file_path)

print(modified_time)

Results

1676929897.4714947