Convert calendar time to local time


#include <time.h>

struct tm *localtime( const time_t *timer );


BlackBerry 10.0.0


A pointer to a time_t object that contains the calendar time that you want to convert.



Use the -l c option to qcc to link against this library. This library is usually included automatically.


The localtime() function converts the calendar time pointed to by timer into local time, storing the information in a struct tm . Whenever you call localtime(), it calls tzset().

You typically get a calendar time by calling time(). That time is Coordinated Universal Time (UTC, formerly known as Greenwich Mean Time or GMT).

The localtime() function places the converted time in a static tm structure that's reused each time you call localtime() or gmtime(). Calling asctime() or ctime() could also change the data in this static buffer.

In a multithreaded application, use localtime_r().

You typically use the date command to set the computer's internal clock using Coordinated Universal Time (UTC). Use the TZ environment variable or _CS_TIMEZONE configuration string to establish the local time zone.


A pointer to the static tm structure containing the time information.


ANSI, POSIX 1003.1

Cancellation point No
Interrupt handler No
Signal handler No
Thread No

Last modified: 2014-06-24

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus