Python datetime.tzname() Method with Example
tzname() method is used in the DateTime class of module DateTime. This method is used to return the time zone name of the DateTime object passed, as a string.
It will return the time zone name of the DateTime object passed, as a string.
So first we need to import the module DateTime, and to get the timezone of the exact place we will simply pass the DateTime stamp generated by datetime.now() function to the tzname() function.
Example 1: Python program that will return the tzinfo() which is none
It is also possible to get the timezone of some other place by explicitly adding the timezone.
Example 2: Python program to add timezone for Asia/Kolkata and get the timezone details
Timezone name: IST
Example 3: Getting the timezone details for asia/Tokyo
Timezone name: JST
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course