newbie printing question

adina_levin at mindspring.com adina_levin at mindspring.com
Tue Oct 16 04:14:57 CEST 2001


In other words,

timestring = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

>>> timestring
'2001-10-15 21:11:09'

which is the date format that mySQL wants.

Thank you, thank you.

"Ignacio Vazquez-Abrams" <ignacio at openservices.net> wrote in message
news:mailman.1003196354.25037.python-list at python.org...
> On Mon, 15 Oct 2001 adina_levin at mindspring.com wrote:
>
> > I'd like to create a string with the current date and time. I've got the
> > mxDateTime library, so far so good.
> >
> > print mxDateTime.now() will generate the date and time to the screen.
write
> > will send it to a file.
> >
> > But how can I assign this to a string?
> >
> > I will be most thankful and embarrassed to hear the answer to this
question.
> > It oughta be obvious!
>
> Use time.localtime() along with time.strftime().
>
> --
> Ignacio Vazquez-Abrams  <ignacio at openservices.net>
>
>    "As far as I can tell / It doesn't matter who you are /
>     If you can believe there's something worth fighting for."
>        - "Parade", Garbage
>
>





More information about the Python-list mailing list