View Full Version : Python timestamps

19th September 2004, 08:45 PM
Anyone know how to axcess the timestamps of a file using python? Or any other of the jpg picture propities?


20th September 2004, 06:40 PM
no one knows?

21st September 2004, 07:53 PM

You have installed python-docs package ? Install it and read the documentation.
These functions are very good documented.


23rd September 2004, 09:10 PM
i think i do but i cant seem to look it up

5th October 2004, 07:34 PM
After you install Python you should see a subdirectory called 'Doc'. In it will be a help file (chm for WinXX).
Open it. Put 'datetime' in the index search box and and select "datetime (built-in module)" from the list that pops up.
You will be placed at section 6.9 in the Python docs. You will see the following subsections:
6.9.1 Available Types
6.9.2 timedelta Objects
6.9.3 date Objects
6.9.4 datetime Objects
6.9.5 time Objects
6.9.6 tzinfo Objects
6.9.7 strftime() Behavior

When you click on one of those objects (classes) you will be shown documenation regarding it.
Included in the documentation will be code snippits explaining how to use the classes.

In your code evoke the classes with an import statement:
import exceptions, string, sys, os, datetime, time
Now you can write code utilizing those imported classes.

I use a commerical libarary: egenix-mx-base-2.0.5.win32-py2.3.exe or the rpm, depending on which platform I am coding in.
It has a DateTime class that is nice. Here's my import of it:


from mx import DateTime,ODBC
from mx.ODBC.Misc import proc
import mx.ODBC.Windows
except ImportError, msg:

print "Error: "+str(msg)

Then I can write functions like:

def DateConvert(self,dDate):

if (dDate == None) or (dDate == ''):

return ('%s' % DateTime.now())
return ('%s' % dDate)

I can preload variables using:
EntryDate = str(DateTime.now())

You should also look at section 5.18, the Calander class.

5th October 2004, 07:49 PM
Opps! Just after I posted my response I noticed you asked about TimeStamps of a FILE, not the using the datetime object.

Check this out: http://effbot.org/zone/python-fileinfo.htm