TZ and tzset Only Use Whole Hours: How to Work Around

Last reviewed: January 19, 1996
Article ID: Q68383
The information in this article applies to:
  • Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
  • Microsoft C for OS/2, versions 5.1, 6.0, and 6.0a
  • Microsoft Visual C++ for Windows, versions 1.0 and 1.5
  • Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, and 2.1

In Microsoft C versions 5.1, 6.0, 6.0a, and 6.0ax, the TZ environment variable and the tzset() function can use only whole hours for time zone adjustments. These functions cannot be used, for example, to calculate the time in Sri Lanka, which is 330 minutes off of GMT.

The only workaround in C 6.x is to use a second environment variable (for example, TZ2) to add thirty minutes to the times passed by functions that return and use local times.

Beginning with C/C++ version 7.0, tzset() and TZ have been enhanced to accept TZ values of the form tzn[+|-]hh[:mm[:ss]][dzn].


Additional reference words: kbinf 6.00 6.00a 6.00ax 1.00 1.50 2.00 2.10
KBCategory: kbprg kbfasttip
KBSubcategory: CRTIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 19, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.