Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python time tzset() method

Python time tzset() method


Description

Python time tzset() reinitializes time-related settings according to the environment variable TZ.

Standard TZ environment variable format:



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

Parameters

- **Jn:** Julian day n (1 <= n <= 365). Leap day (February 29) is not counted. - **n:** Julian day (0 <= n <= 365). Leap day (February 29) is counted - **Mm.n.d:** the month, week, and day of the date. w=1 means the first week of the month, and w=5 means the last week of the month. - **time:** (optional) the time when DST takes effect (24-hour clock). Defaults to 02:00 (local time in the specified time zone).

Syntax



time.tzset()

Parameters

Return Value

This function has no return value.

Example

The following example shows how to use the tzset() function:



#!/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 output of the above example is:



13:00:40 02/17/09 EST

05:00:40 02/18/09 AEDT