Current date and time

Jeff jam at quark.emich.edu
Tue Jun 20 22:05:32 EDT 2000


On Tue, Jun 20, 2000 at 09:18:51PM -0400, Aeneas <shan_mu wrote:
> How do you format the result as--
> "Tuesday  20 June 2000  21:18hr" ?
> Thanks.
> 

greetings,

there are many ways to do this (as with everything), but here's what I came
up with:

[~] [9:53pm] [jam at toast-pts/8] % python
Python 1.5.2 (#1, Feb  1 2000, 16:32:16)  [GCC egcs-2.91.66 19990314/Linux
(egcs- on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import time
>>> t = time.localtime(time.time())
>>> print time.strftime("%A %d %B %Y %H:%Mhr", t)
Tuesday 20 June 2000 21:55hr

for examples of the parameters available in strftime, check the man page
('man strftime'). you can also find documentation from the python website
about the 'time' module here:
http://www.python.org/doc/current/lib/module-time.html

hope that helps a little.. have fun! ;)

regards,
J
-- 
|| visit gfd <http://quark.emich.edu/>
|| psa member -- <http://www.python.org/psa/> 




More information about the Python-list mailing list