English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
funzione della libreria C struct tm *gmtime(const time_t *timer) usare timer valori per riempire tm struttura, utilizzata anche per rappresentare l'ora universale coordinata (UTC), conosciuta anche come il tempo di Greenwich Mean Time (GMT).
Di seguito è riportata la dichiarazione della funzione gmtime().
struct tm *gmtime(const time_t *timer)
La funzione restituisce un puntatore alla struttura tm, che contiene le informazioni temporali riempite. Di seguito sono riportati i dettagli della struttura timeptr:
struct tm { int tm_sec; /* Secondi, range da 0 a 59 */ int tm_min; /* Minuti, range da 0 a 59 */ int tm_hour; /* Ora, range da 0 a 23 */ int tm_mday; /* Giorno del mese, range da 1 a 31 */ int tm_mon; /* Mese, range da 0 a 11 */ int tm_year; /* Anno dal 1900 */ int tm_wday; /* Giorno della settimana, range da 0 a 6 */ int tm_yday; /* Giorno dell'anno, range da 0 a 365 */ int tm_isdst; /* Orario estivo */ };
Il seguente esempio dimostra l'uso della funzione gmtime().
#include <stdio.h> #include <time.h> #define BST (+1) #define CCT (+8) int main () { time_t rawtime; struct tm *info; time(&rawtime); /* Ottenere l'ora GMT */ info = gmtime(&rawtime ); printf("Ora universale corrente:\n"); printf("Londra:%2d:%02d\n", (info->tm_hour+BST)%24, info->tm_min); printf("Cina:%2d:%02d\n", (info->tm_hour+CCT)%24, info->tm_min); return(0); }
让我们编译并运行上面的程序,这将产生以下结果:
当前的世界时钟: 伦敦:14:10 中国:21:10