Skip to Content
Menu
This question has been flagged
1 Reply
4830 Views

Assuming that the current time is '12/08/2014 03:24:05 ' and rectified in the database and the time is '12/08/2014 09:54:05'; gather that this adding seven hours.The user can set the time zone 'Asia/Kolkata'.Taking the approximate timezone create_date field.I want that proper time in database. 

Anyone have any idea ?

Avatar
Discard
Best Answer

Since OpenERP 6.1, the timezone of all Python operations happening on the server-side (and in modules) is forced to be UTC. This was a design decision explained in various places. The rendering of datetime values in the user's timezone is meant to be done on the client-side exclusively.

from openerp.osv import fields
from datetime import datetime
my_date = fields.datetime.context_timestamp(cr, uid, datetime.now(), context=context)
print "My Datetime: ", my_date
print "Hour: ", my_date.hour

My Datetime: 2013-06-06 12:28:22.249559+05:30
Hour: 12
Avatar
Discard