[Previous]
[Contents]
[Next]

time()

determine the current calendar time

Synopsis:

#include <time.h>
time_t time( time_t *tloc );

Description:

The time() function determines the current calendar time, and encodes it into the type time_t.

The time represents the time since 00:00:00, January 1, 1970 Coordinated Universal Time (UTC) (formerly known as Greenwich Mean Time (GMT)). 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:

The current calendar time. If tloc isn't NULL, the current calendar time is also stored in the object pointed to by tloc.

Examples:

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

void main()
  {
    time_t time_of_day;

    time_of_day = time( NULL );
    printf( "It is now: %s", ctime( &time_of_day ) );
  }

produces the output:

It is now: Fri Dec 25 15:58:42 1987

Classification:

ANSI, POSIX 1003.1

Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

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


[Previous]
[Contents]
[Next]