C語言標準庫
C語言標準庫
<assert.h> - C語言標準庫
C函數庫宏 assert()
<ctype.h> - C語言標準庫
isalnum() - C函數
isalpha() - C函數
iscntrl() - C函數
isdigit() - C函數
isgraph() - C函數
islower() - C函數
isprint() - C函數
ispunct() - C函數
isspace() - C函數
isupper() - C函數
isxdigit() - C函數
tolower() - C函數
toupper() - C函數
<errno.h> - C語言標準庫
errno - C語言宏
EDOM - C語言宏
ERANGE - C語言宏
<float.h> - C語言標準庫
<limits.h> - C語言標準庫
<locale.h> - C語言標準庫
setlocale() - C函數
localeconv() - C函數
<math.h> - C語言標準庫
acos() - C函數
asin() - C函數
atan() - C函數
atan2() - C函數
cos() - C函數
sin() - C函數
sinh() - C函數
tanh() - C函數
exp() - C函數
frexp() - C函數
ldexp() - C函數
log() - C函數
log10() - C函數
modf() - C函數
pow() - C函數
sqrt() - C函數
ceil() - C函數
fabs() - C函數
floor() - C函數
fmod() - C函數
<setjmp.h> - C語言標準庫
setjmp() - C函數
longjmp() - C函數
<signal.h> - C語言標準庫
signal() - C函數
raise() - C函數
<stdarg.h> - C語言標準庫
va_start() - C函數
va_arg() - C函數
va_end() - C函數
<stddef.h> - C語言標準庫
NULL - C函數
offsetof() - C函數
<stdio.h> - C語言標準庫
clearerr() - C庫函數
fclose() - C庫函數
feof() - C庫函數
ferror() - C庫函數
fflush() - C庫函數
fgetpos() - C庫函數
fopen() - C語言庫函數
fread() - C語言庫函數
freopen() - C語言庫函數
fseek() - C語言庫函數
fsetpos() - C語言庫函數
ftell() - C語言庫函數
fwrite() - C語言庫函數
remove() - C語言庫函數
rename() - C語言庫函數
rewind() - C語言庫函數
setbuf() - C語言庫函數
setvbuf() - C語言庫函數
tmpfile() - C語言庫函數
tmpnam() - C語言庫函數
fprintf() - C語言庫函數
printf() - C語言庫函數
sprintf() - C語言庫函數
vfprintf() - C語言庫函數
vprintf() - C語言庫函數
vsprintf() - C語言庫函數
fscanf() - C語言庫函數
scanf() - C語言庫函數
sscanf() - C語言庫函數
fgetc() - C語言庫函數
fgets() - C語言庫函數
fputc() - C語言庫函數
fputs() - C語言庫函數
getc() - C語言庫函數
getchar() - C語言庫函數
gets() - C語言庫函數
putc() - C語言庫函數
putchar() - C語言庫函數
puts() - C語言庫函數
ungetc() - C語言庫函數
perror() - C語言庫函數
<stdlib.h> - C語言標準庫
atof() - C語言庫函數
atoi() - C語言庫函數
atol() - C語言庫函數
strtod() - C語言庫函數
strtol() - C語言庫函數
strtoul() - C語言庫函數
calloc() - C語言庫函數
free() - C語言庫函數
malloc() - C語言庫函數
realloc() - C語言庫函數
abort() - C語言庫函數
atexit() - C語言庫函數
exit() - C語言庫函數
getenv() - C語言庫函數
system() - C語言庫函數
bsearch() - C語言庫函數
qsort() - C語言庫函數
abs() - C語言庫函數
div() - C語言庫函數
labs() - C語言庫函數
ldiv() - C語言庫函數
rand() - C語言庫函數
srand() - C語言庫函數
mblen() - C語言庫函數
mbstowcs() - C語言庫函數
mbtowc() - C語言庫函數
wcstombs() - C語言庫函數
wctomb() - C語言庫函數
<string.h> - C語言標準庫
memchr() - C語言庫函數
memcmp() - C語言庫函數
memcpy() - C語言庫函數
memmove() - C語言庫函數
memset() - C語言庫函數
strcat() - C語言庫函數
strncat() - C語言庫函數
strchr() - C語言庫函數
strcmp() - C語言庫函數
strncmp() - C語言庫函數
strcoll() - C語言庫函數
strcpy() - C語言庫函數
strcspn() - C語言庫函數
strerror() - C語言庫函數
strlen() - C語言庫函數
strpbrk() - C語言庫函數
strrchr() - C語言庫函數
strspn() - C語言庫函數
strstr() - C語言庫函數
strtok() - C語言庫函數
strxfrm() - C語言庫函數
<time.h> - C語言標準庫
asctime() - C語言庫函數
clock() - C語言庫函數
ctime() - C語言庫函數
difftime() - C語言庫函數
gmtime() - C語言庫函數
localtime() - C語言庫函數
mktime() - C語言庫函數
strftime() - C語言庫函數
time() C語言

gmtime() - C語言庫函數

C庫函數 struct tm *gmtime(const time_t *timer) 使用定時器所指向的數值,以填補atm結構的值,表示對應的時間,以協調通用時間(UTC)或GMT時區表示。

聲明

以下是gmtime() 函數的聲明。

struct tm *gmtime(const time_t *timer)

參數

  • timeptr -- 這是一個time_t值表示日曆時間的指針。

返回值

這個函數返回指向tm結構和下面的時間信息填寫。timeptr結構的細節:

struct tm { int tm_sec; /* seconds, range 0 to 59 */ int tm_min; /* minutes, range 0 to 59 */ int tm_hour; /* hours, range 0 to 23 */ int tm_mday; /* day of the month, range 1 to 31 */ int tm_mon; /* month, range 0 to 11 */ int tm_year; /* The number of years since 1900 */ int tm_wday; /* day of the week, range 0 to 6 */ int tm_yday; /* day in the year, range 0 to 365 */ int tm_isdst; /* daylight saving time */ };

例子

下面的例子顯示gmtime() 函數的用法。

#include <stdio.h> #include <time.h> #define BST (+1) #define CCT (+8) int main () { time_t rawtime; struct tm *info; time(&rawtime); /* Get GMT time */ info = gmtime(&rawtime ); printf("Current world clock:
"); printf("London : %2d:%02d
", (info->tm_hour+BST)%24, info->tm_min); printf("China : %2d:%02d
", (info->tm_hour+CCT)%24, info->tm_min); return(0); }

讓我們編譯和運行上面的程序,這將產生以下結果:

Current world clock:
London : 14:10
China : 21:10