[Previous] [Contents] [Next]

localtime_r()

Convert calendar time to local time

Synopsis:

#include <time.h>

struct tm* localtime_r( const time_t* timer,
                        struct tm* result );

Library:

libc

Description:

The localtime_r() function converts the calendar time pointed to by timer into local time, storing the information in the struct tm, result. Whenever localtime_r() is called, the tzset() function is also called.

The calendar time is usually obtained by using the time() function. That time is Coordinated Universal Time (UTC, formerly known as Greenwich Mean Time or GMT).

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

Returns:

A pointer to result, the struct tm.

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

asctime(), asctime_r(), clock(), ctime(), ctime_r(), difftime(), gmtime(), gmtime_r(), localtime(), mktime(), strftime(), time(), tm, tzset()


[Previous] [Contents] [Next]