Convert time_t value to tm structure in local time: How to use localtime
#include <stdio.h> #include <time.h> int main () { time_t rawtime; struct tm *tminfo; time ( &rawtime ); tminfo = localtime ( &rawtime ); printf ( "Current date and time are: %s", asctime (tminfo) ); return 0; }