Re: Get age of a file/dir
- From: "Simon Forman" <rogue_pedro@xxxxxxxxx>
- Date: 1 Aug 2006 17:51:01 -0700
Actually this has nothing to do with datetime.datetime -- he's asking
how to find the created time of the directory.
Python has a builtin module called "stat" (afer sys/stat.h) which
includes ST_ATIME, ST_MTIME, ST_CTIME members which are times accessed,
modified, and created, respectively.
Carl J. Van Arsdall wrote:
I've been looking around the OS module and I haven't found anything
useful yet. Does anyone know how to get the age of a file or directory
in days? I'm using unix and don't seem to find anything that will help
me. The only function that comes close so far is
However this only gets creation time on Windows, on Unix it gets the the
time of the last change. Any ideas?
Carl J. Van Arsdall
Build and Release
You should check out the datetime module. And convert dates to an
today = datetime.date.today().toordinal()
age = today - datetime.date(year, month, day).toordinal()
No, the st_ctime member isn't the creation time on *nix, from the os
module docs: "st_ctime (platform dependent; time of most recent
metadata change on Unix, or the time of creation on Windows)"
I hope somebody does post a solution to this, as I'd like to know how
to get the creation time of a file on linux, et. al.
It may be impossible:
- Prev by Date: Re: python under earthlink hosting?
- Next by Date: Re: Multiple Telnet sessions through one script
- Previous by thread: Re: Get age of a file/dir
- Next by thread: Re: Get age of a file/dir