Printing date a file

Michael J. Fromberger Michael.J.Fromberger at Clothing.Dartmouth.EDU
Tue Aug 24 15:15:30 EDT 2004


In article <mailman.2296.1093373725.5135.python-list at python.org>,
 Kory Wheatley <wheakorypersonal at yahoo.com> 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
> 

  import time

  print time.strftime("%m/%d/%Y or %m-%d-%Y")

See also:
  http://www.python.org/doc/2.3.4/lib/module-time.html
  

Cheers,
-M

-- 
Michael J. Fromberger             | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/  | Dartmouth College, Hanover, NH, USA



More information about the Python-list mailing list