[Previous]
[Contents]
[Next]

gmtime(), _gmtime()

convert calendar time to a broken-down time

Synopsis:

#include <time.h>
struct tm * gmtime( const time_t *timer );
struct tm *_gmtime( const time_t *timer,
            struct tm *tmbuf );

Description:

The gmtime() functions convert the calendar time pointed to by timer into a broken-down time, expressed as Coordinated Universal Time (UTC) (formerly known as Greenwich Mean Time (GMT)).

The function _gmtime places the converted time in the tm structure pointed to by tmbuf, and the gmtime() function places the converted time in a static structure that is re-used each time gmtime() is called.

The time set on the computer with the QNX date command reflects Coordinated Universal Time (UTC). The environment variable TZ is used to establish the local time zone. See the Global Data and the TZ Environment Variable chapter for a discussion of how to set the time zone.

Returns:

A pointer to a structure containing the broken-down time.

Examples:

#include <stdio.h>
#include <time.h>

void main()
  {
    time_t time_of_day;
    char buf[26];
    struct tm tmbuf;

    time_of_day = time( NULL );
    _gmtime( &time_of_day, &tmbuf );
    printf( "It is now: %.24s GMT\n",
        _asctime( &tmbuf, buf ) );
  }

produces the output:

It is now: Fri Dec 25 15:58:27 1987 GMT

Classification:

gmtime() is ANSI; _gmtime() is WATCOM.
Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

asctime(), clock(), ctime(), difftime(), localtime(), mktime(), strftime(), time(), tzset()

The tm structure is described in the section on <time.h> in the Header Files chapter.


[Previous]
[Contents]
[Next]