Latest web development tutorials

Python time tzset () method

description

Python time tzset () based on the environment variable TZ re-initialization settings.

Standard TZ environment variable format:

std offset [dst [offset [,start[/time], end[/time]]]]

parameter

  • std and dst: initials three or more times.Passed to time.tzname.
  • offset: offset from UTC, in the format: [+ | -] hh [ : mm [: ss]] {h = 0-23, m / s = 0-59}.
  • start [/ time], end [ / time]: Date when DST begins to take effect.Format mwd - month for the day, date and number of weeks. w = 1 refers to the first week of the month, and w = 5 refers to the last week of the month. 'Start' and 'end' can be one of the following formats:
    • Jn: Julian day n (1 <= n <= 365).Leap Year Day (February 29) is not counted.
    • n: Julian day (0 <= n <= 365 ).Leap Year Day (February 29) counted
    • Mm.nd: day of the month, date and number of weeks.w = 1 refers to the first week of the month, and w = 5 refers to the last week of the month.
    • time: (optional) time (24-hour) DST came into effect when.The default value is 02:00 (local time zone specified time).

grammar

time.tzset()

parameter

  • NA.

return value

This function has no return value.

Examples

The following example shows tzset () function to use:

#!/usr/bin/python
import time
import os

os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
time.tzset()
print time.strftime('%X %x %Z')

os.environ['TZ'] = 'AEST-10AEDT-11,M10.5.0,M3.5.0'
time.tzset()
print time.strftime('%X %x %Z')

The above example output is:

13:00:40 02/17/09 EST
05:00:40 02/18/09 AEDT