locatime and strftime
Scott Holmes
scottholmes at sbcglobal.net
Thu Aug 14 17:14:40 EDT 2003
Replying to myself, I've changed to gmtime rather than localtime and
this solves my immediate problem. This is a bit counter-intuitive,
however. I suspect I still have an issue with locale.
Scott Holmes wrote:
> I've just run into an issue with the use of localtime and strftime. It
> appears that localtime is dropping the value provided by the database
> record by eight (8) hours. It is only doing this for the representation
> of time (H:M) not the date. I have this bit of code:
>
> print "DB Time: ", app_date, " ", start_time, " Python
> Time:",time.strftime('%m/%d/%Y', time.localtime(app_date)), " ",
> time.strftime('%H:%M', time.localtime(start_time))
>
> This results in:
>
> DB Time: 2000-12-31 00:00:00.00 06:45:00.00 Python Time: 12/31/2000
> 22:45
>
> Actually, I did this for a number of dates and times. I would expect
> the python date to be 12/30/2000
>
> I would like to avoid this conversion of times altogether and just trust
> the value contained in the database. I suspect it may have something to
> do with locale, but I haven't delved that far into Python yet to know
> how to deal with that issue.
>
--
---------------------------------------------------------------------
Scott Holmes http://sholmes.ws
http://pages.sbcglobal.net/scottholmes
scottholmes at sbcglobal.net
Independent Programmer/Analyst Passport 4GL
PHP HTML Composer PostgreSQL Informix 4GL, SQL
---------------------------------------------------------------------
There are more things in heaven and earth, Horatio,
than are dreamt of in your philosophy
---------------------------------------------------------------------
More information about the Python-list
mailing list