Datetime module
Mark McEahern
marklists at mceahern.com
Mon Jan 10 07:41:06 EST 2005
rublind at gmail.com wrote:
>I am writing a script that acts as an AIM bot [using twisted.IM's base
>scripts] and I want to add a logging feature. I got it to log who sends
>what to whom, but what I want to add is the date and time that the
>message was sent (or recieved by the bot), I tried to look at datetime
>on my own, and I couldn't get anything to work.
>Anyone know a simple way to get the current date and/or time?
>
>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2005, 1, 10, 6, 39, 56, 64000)
>>> print datetime.datetime.now()
2005-01-10 06:40:03.705000
>>>
You may also want to consider using the logging module.
// m
More information about the Python-list
mailing list