English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Funzione della libreria C struct tm *localtime(const time_t *timer) Usare il valore di timer per riempire tm Struttura.timer Il valore tm Struttura, rappresentata nel fuso orario locale.
Di seguito è riportata la dichiarazione della funzione localtime().
struct tm *localtime(const time_t *timer)
timer -- Questo è un puntatore a un valore time_t che rappresenta il tempo calendario.
La funzione restituisce un puntatore a tm Puntatore a struttura, la struttura contiene informazioni temporali riempite. Di seguito sono riportati i dettagli della struttura tm:
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 */ };
Di seguito è riportato un esempio di utilizzo della funzione localtime().
#include <stdio.h> #include <time.h> int main() { time_t rawtime; struct tm *info; char buffer[80]; time(&rawtime); info = localtime(&rawtime); printf("当前的本地时间和日期:%s", asctime(info)); return(0); {}
让我们编译并运行上面的程序,这将产生以下结果:
当前的本地时间和日期:Thu Aug 23 09:12:05 2016