Get the current date, python 2.2

Yongjian Xu jimxu at google.com
Fri Jun 15 17:44:46 EDT 2007


time.strftime('%Y-%m-%d', time.localtime()) gives you just the date format.

Jim

On 6/15/07, nano <nano at nano.ono> wrote:
>
> Using python 2.2 what is the simplest way to get the current date value?
> I have looked in so many places. The question is often asked and the
> usual response indicates how to get the current date and time like
>
> now = time.localtime()
>
> I want just the date, like 2007-06-15. The value will go into a
> postgresql Date type column.
>
> Also, if postgres field of this type is set to time.localtime(), is the
> time portion of the date discarded, or stored 'invisibly', of will there
> be an error of some type? Just thought someone here might know.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Yongjian (Jim) Xu
===========
Sysops
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070615/a1256599/attachment.html>


More information about the Python-list mailing list