Datetime module

Binu K S binux.lists at gmail.com
Mon Jan 10 00:55:32 EST 2005


The time module will do.
>>> import time
>>> time.ctime()
'Mon Jan 10 11:17:54 2005'

Use strftime if you need to format the time differently.
>>> time.strftime("%Y-%m-%d %H:%m:%S",time.localtime())
'2005-01-10 11:01:45'

On 9 Jan 2005 21:46:12 -0800, rublind at gmail.com <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?
> 
> Thanks!
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list