C Programming Code Examples C > Conversions Code Examples Convert time_t value to tm structure as UTC time: how to use gmtime Convert time_t value to tm structure as UTC time: how to use gmtime #include <stdio.h> #include <time.h> #define PST (-8) #define CET (1) #define BJ (8) int main () { time_t rawtime; struct tm *p; time ( &rawtime ); p = gmtime ( &rawtime ); printf ("Time in Los Angeles: %2d:%02d\n", p->tm_hour+PST, p->tm_min); printf ("Time in Berlin: %2d:%02d\n", p->tm_hour+CET, p->tm_min); printf ("Time in Bei Jing: %2d:%02d\n", p->tm_hour+BJ, p->tm_min); return 0; }