gmtime Function

Converts calendar time to time structure expressed as Universal Time Coordinated (UTC) also known as Greenwich Mean Time (GMT).

Include

<time.h>

Prototype

struct tm *gmtime(const time_t *tod);

Argument

tod
pointer to stored time

Return Value

Returns the address of the time structure.

Remarks

This function breaks down the tod value into the time structure of type tm. By default, the compiler returns the time as instruction cycles. With this default, gmtime and localtime will be equivalent, except gmtime will return tm_isdst (Daylight Savings Time flag) as zero to indicate that Daylight Savings Time is not in effect.

Example

#include <time.h>
#include <stdio.h>

int main(void)
{
  time_t timer;
  struct tm *newtime;

  timer = 1066668182; /* Mon Oct 20 16:43:02 2003 */

  newtime = gmtime(&timer);
  printf("UTC time = %s\n", asctime(newtime));
}

Example Output

UTC time = Mon Oct 20 16:43:02 2003