Printing date a file

wes weston wweston at att.net
Tue Aug 24 15:34:46 EDT 2004


Kory Wheatley wrote:
> In Python how would you print the date in a file, I
> have a logging program written in python and for each
> new recorded added to the file, I would like to print
> the 
> date, something like this below:
> 
> 08/24/2004 or 08-24-2004
> 
> --
> Kory Wheatley
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!
> http://promotions.yahoo.com/new_mail 

Kory,
    Works. Maybe a better way.
wes

 >>> import datetime
 >>> d = datetime.datetime(2004,1,1).today()
 >>> d
datetime.datetime(2004, 8, 24, 12, 29, 25, 784935)
 >>> d.year
2004
 >>> d.month
8
 >>> d.day
24




More information about the Python-list mailing list