Python time altzone() Method
Last Updated :
05 Nov, 2021
Python altzone() method is used to return the offset of the local DST timezone, in seconds west of UTC. We can also get the current time between the current time zone and UTC by using the timezone and altzone method.
Syntax:
time.altzone
Example:
Python3
import time
print (time.altzone)
|
Output:
25200
Example: Python program to get the current time between current time zone and UTC by using timezone and altzone method
Python3
import time
def get_zone():
dst = time.daylight and time.localtime().tm_isdst
offset = time.altzone if dst else time.timezone
westerly = offset > 0
minutes, seconds = divmod ( abs (offset), 60 )
hours, minutes = divmod (minutes, 60 )
return '{}{:02d}{:02d}' . format ( '-' if westerly else '+' , hours, minutes)
get_zone()
|
Output:
+0000
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...