date

Alex Martelli aleaxit at yahoo.com
Tue May 8 18:37:43 EDT 2001


"LC" <lco at gofuse.com> wrote in message
news:9d9obt$p9s$1 at nntp2-cm.news.eni.net...
> Can someone tell me how can I retrieve the date using Python on a Windows
> 2000 machine? TIA

D:\Python21>python
Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import time
>>> print time.asctime()
Wed May 09 00:35:06 2001
>>>

This works in Python 2.1, and assuming you want the local data
(it's still May 8 in many parts of the world:-) as a string.  But
it's easy with other functions of the time module to get GMT
time, format things differently, etc, and even in older Python
versions the functionality is all there, you just have to use
explicit calls for time.localtime(time.time()) rather than having
it be a handy default as in Python 2.1.

It works on any platform that supports Python, I believe.


Alex






More information about the Python-list mailing list