Get System Date?

Dave davidworley at gmail.com
Sun Feb 5 13:22:05 EST 2006


Dustan,

Python has a module called, appropriately, "time". Like most things in
Python, it's fairly simple and straightforward to use.

The module is documented here:
http://docs.python.org/lib/module-time.html

Breifly, though, the format you want is built right into time:

>>> import time
>>> now = time.localtime()
>>> print now
(2006, 2, 5, 13, 21, 15, 6, 36, 0)

So to get the year, month, and day you would just have to manipulate
the values returned by time.gmtime().

- Dave




More information about the Python-list mailing list