Solve the odoo time zone problem

Solve the odoo time zone problem

The time zone in the python program
··· #The time zone
must be changed before calling datetime. Otherwise, the change will not take effect. This may be bugs Python
Import ( 'OS') Environ [ 'the TZ'] = 'UTC'.
Import datetime
Print (datetime.datetime.now ()
2019-11-27 01: 31 is: 14.868105
?????
there are normal.

odoo

Look at the odoo code
...
import ('os').environ['TZ'] ='UTC'
import odoo

if name == " main ":
import datetime
print(datetime.datetime.now())
print(datetime.datetime.utcnow())
odoo.cli.main()
···It
has been started with pycharm
but it is not UTC time . Until the time zone bug above was found. I realized that datetime might be called first when pycharm was started. So the time zone is invalid.
Starting with the command line is completely normal

solve

Found that pycharm can have environment variable settings.
Insert picture description here

Guess you like

Origin blog.csdn.net/sr50611/article/details/103269668