Setting the time zone

QNX SDP8.0User's GuideUser

On the command line, you can set the time zone by setting the TZ environment variable or the _CS_TIMEZONE configuration string.

Note:
If TZ isn't set, the system uses the value of the _CS_TIMEZONE configuration string instead. The POSIX standards include the TZ environment variable; _CS_TIMEZONE is a QNX OS implementation. The description below applies to both.

Various time functions use the time-zone information to compute times relative to Coordinated Universal Time (UTC), formerly known as Greenwich Mean Time (GMT). You usually set the time on your computer to UTC. Use the date command if the time isn't automatically maintained by the computer hardware.

You can set the TZ environment variable by using the env utility or the export shell command. You can use setconf to set _CS_TIMEZONE. For example:
env TZ=PST8PDT
export TZ=PST8PDT
setconf _CS_TIMEZONE PST8PDT

The TZ environment variable or _CS_TIMEZONE string can be in POSIX or zoneinfo format:

  • POSIX format is as follows (spaces are for clarity only):
    std offset dst offset, rule
    The expanded format is as follows:
    stdoffset[dst[offset][,start[/time],end[/time]]]

    The components are:

    std and dst
    Three or more letters that you specify to designate the standard or daylight saving time zone. Only std is required. If you omit dst, then daylight saving time doesn't apply in this locale. Upper- and lowercase letters are allowed. Any characters except for a leading colon (:), digits, comma (,), minus (-), plus (+), and ASCII NUL (\0) are allowed.
    offset
    The value you must add to the local time to arrive at Coordinated Universal Time (UTC). The offset has the form:
    hh[:mm[:ss]]

    Minutes (mm) and seconds (ss) are optional. The hour (hh) is required; it may be a single digit.

    The offset following std is required. If no offset follows dst, summer time is assumed to be one hour ahead of standard time.

    You can use one or more digits; the value is always interpreted as a decimal number. The hour may be between 0 and 24; the minutes (and seconds), if present, between 0 and 59. If preceded by a -, the time zone is east of the prime meridian; otherwise it's west (which may be indicated by an optional preceding +).

    rule
    Indicates when to change to and back from summer time. The rule has the form:
    date/time,date/time
    where the first date describes when the change from standard to summer time occurs, and the second date describes when the change back happens. Each time field describes when, in current local time, the change to the other time is made.

    The format of date may be one of the following:

    Jn
    The Julian day n (1 <= n <= 365). Leap days aren't counted. That is, in all years—including leap years—February 28 is day 59 and March 1 is day 60. It's impossible to refer explicitly to the occasional February 29.
    n
    The zero-based Julian day (0 <= n <= 365). Leap years are counted; it's possible to refer to February 29.
    Mm.n.d
    The dth day (0 <= d <= 6) of week n of month m of the year (1 <= n <= 5, 1 <= m <= 12, where week 5 means the last d day in month m, which may occur in the fourth or fifth week). Week 1 is the first week in which the dth day occurs. Day zero is Sunday.

    The time has the same format as offset, except that no leading sign (+ or -) is allowed. The default, if time is omitted, is 02:00:00.

  • The zoneinfo format is as follows:
    :area/location

    For example, :Asia/Tokyo corresponds to Japanese Standard Time.

    Note:
    Time zones specified in this format require a database that you can obtain from the Internet Assigned Numbers Authority at https://www.iana.org/time-zones. Download and untar the archive on your development host, build it following the instructions in the README file, and include the compiled database on your target system. You must install the database in /usr/share/zoneinfo.
Page updated: