The gmtime function breaks down the timer value and stores it in a statically allocated structure of type tm, defined in TIME.H. The value of timer is usually obtained from a call to the time function.
TM * gmtime( const time_t * timer )
- Pointer to stored time. The time is represented as seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC).
a pointer to a structure of type tm. The fields of the returned structure hold the evaluated value of the timer argument in UTC rather than in local time. Each of the structure fields is of type int, as follows:
tm_sec: Seconds after minute (0 - 59)
tm_min: Minutes after hour (0 - 59)
tm_hour:Hours since midnight (0 - 23)
tm_mday:Day of month (1 - 31)
tm_mon: Month (0 - 11; January = 0)
tm_year:Year (current year minus 1900)
tm_wday:Day of week (0 - 6; Sunday = 0)
tm_yday:Day of year (0 - 365; January 1 = 0)
tm_isdst:Always 0 for gmtime
The gmtime, mktime, and localtime functions use the same single, statically allocated structure to hold their results. Each call to one of these functions destroys the result of any previous call.
If timer represents a date before midnight, January 1, 1970, gmtime returns NULL. There is no error return.
struct tm *nowtime;
time( &aclock ); // Get time in seconds
nowtime = gmtime( &aclock ) ;
// printf( "The current date and time are: %s", asctime(nowtime) );
printf("Now UTC time is %d :%d :%d ",nowtime->tm_hour,nowtime->tm_min,nowtime->tm_sec);
mktime, localtime, time
header to Include