Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,868 questions

51,791 answers

573 users

How to get time zone info for specific place (e.g., Europe/Amsterdam) in Python

1 Answer

0 votes
import time  
import os

def print_time_zone_info():         
    print('TZ:', os.environ.get('TZ', '(not set)'))         
    print('tzname:', time.tzname)         
    print('Zone: {} ({})'.format(time.timezone, (time.timezone / 3600)))         
    print('daylight:', time.daylight)         
    print('Time:', time.ctime())



os.environ['TZ'] = 'Europe/Amsterdam'        
time.tzset()         
    
print_time_zone_info()



'''
run:

TZ: Europe/Amsterdam
tzname: ('CET', 'CEST')
Zone: -3600 (-1.0)
daylight: 1
Time: Mon Jun  3 12:32:05 2019

'''

 



answered Jun 3, 2019 by avibootz
...