function
<ctime>
gmtimestruct tm * gmtime (const time_t * timer);
Convert time_t to tm as UTC time
Uses the value pointed by timer to fill a tm structure with the values that represent the corresponding time, expressed as a UTC time (i.e., the time at the GMT timezone).For a local time alternative, see localtime.
The returned value points to an internal object whose validity or value may be altered by any subsequent call to gmtime or localtime.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* gmtime example */
#include <stdio.h> /* puts, printf */
#include <time.h> /* time_t, struct tm, time, gmtime */
#define MST (-7)
#define UTC (0)
#define CCT (+8)
int main ()
{
time_t rawtime;
struct tm * ptm;
time ( &rawtime );
ptm = gmtime ( &rawtime );
puts ("Current time around the World:");
printf ("Phoenix, AZ (U.S.) : %2d:%02d\n", (ptm->tm_hour+MST)%24, ptm->tm_min);
printf ("Reykjavik (Iceland) : %2d:%02d\n", (ptm->tm_hour+UTC)%24, ptm->tm_min);
printf ("Beijing (China) : %2d:%02d\n", (ptm->tm_hour+CCT)%24, ptm->tm_min);
return 0;
}
Current time around the World: Phoenix, AZ (U.S.) : 8:22 Reykjavik (Iceland) : 15:22 Beijing (China) : 23:22
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4