I'm trying to wrap my head around different timezones. How can I run python in a given timezone (overriding the system's timezone)?
You can use the TZ
environment variable:
$ python -c 'import time; print(time.tzname)'
('GMT', 'BST')
$ TZ='Europe/Stockholm' python -c 'import time; print(time.tzname)'
('CET', 'CEST')
The time
and datetime
modules will honor this.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments