[Zope] strftime and timezone

Hong Yaun hongyuan at homemaster.cn
Mon Mar 14 08:43:02 EST 2005


My zope application accesses a Postgres table with a timestamp field 
'create_date' through ZPsycopgDA and I want to use strftime to format 
the date the way I like.

However, I find that strftime returns a value that is not the same time 
as the original one, very likely due to some behind-scene timezone 
adjustment, which I don't understand and don't know how to control. The 
following PythonScript code is an illustration of my problem:

msg=context.get_some_message
t=msgs.create_date
print t
print t.strftime('%Y-%m-%d %H:%M:%S')
return printed

When called, the script returns:

2005/03/09 03:36:45 US/Central
2005-03-09 17:36:45

The question is, where does the 'create_date' object get the timezone 
information for the formatting, and how to achieve my desired output, 
that is '2005-03-09 03:36:45'? By the way, 'create_date' doesn't seem to 
be a Zope DateTime object, for when I tested with:

t=DateTime()
print t
print t.strftime('%Y-%m-%d %H:%M:%S')

The two prints give the same time value.

For your information, in my ZPsycopgDA property, I have choosen the 
option: 'Use Zope's internal DateTime module
(instead of mxDateTime)'. My zope version: 2.7.4 under Linux.

Thanks for your help.

Hong Yuan


More information about the Zope mailing list