gmtime,gmtime_r,localtime,localtime_r


The following program demonstrates the gmtime, gmtime_r, localtime, and localtime_r family of library functions, which take a time_t (the number of seconds since the UNIX Epoch (January 1, 1970)), and return a struct tm (also called a broken-down time). A struct tm has fields for the year, month, day of the month, and so forth. gmtime returns an abolute broken-down time (that is, the UTC time (also known as Greenwich Mean Time or Zulu time)), whereas localtime expresses the time relative to the user's specified timezone and daylight savings regime. gmtime_r and localtime_r are reentrant versions of gmtime and localtime, respectively.

The program gets the current time and prints a timestamp according to UTC time and local time. The program then recomputes these timestamps using the reentrant versions of these functions.

gmtime.c