Syntax
#include <time.h> struct tm *localtime(const time_t *timeval);Description
localtime breaks down timeval, corrects for the local time zone and Daylight Saving Time, if appropriate, and stores the corrected time in a structure of type tm. See gmtime for a description of the fields in a tm structure.
The time value is usually obtained by a call to the time function.
Note:
localtime returns a pointer to the structure result. If unsuccessful, it returns NULL.
This example queries the system clock and displays the local time.
#include <time.h>#include <stdio.h>
int main(void)
{
struct tm *newtime;
time_t ltime;
time(<ime);
newtime = localtime(<ime);
printf("The date and time is %s", asctime(newtime));
return 0;
/****************************************************************************
The output should be similar to:
The date and time is Wed Oct 31 15:00:00 1995
****************************************************************************/
}
Related Information