Converts time to local time.
struct tm * localtime (const time_t * timer);
This function has the following parameter.
A pointer to a tm structure for the local time representation of timer.
#include <stdio.h> /* puts, printf */
#include <time.h> /* time_t, struct tm, time, localtime */
// w w w . j a v a 2 s .co m
int main (){
time_t rawtime;
struct tm * timeinfo;
time (&rawtime);
timeinfo = localtime (&rawtime);
printf ("Current local time and date: %s", asctime(timeinfo));
return 0;
}
The code above generates the following result.
#include <time.h>
#include <stdio.h>
int main(void)
{
time_t t = time(NULL);
printf("UTC: %s", asctime(gmtime(&t)));
printf("local: %s", asctime(localtime(&t)));
}
The code above generates the following result.