フォーマット
#include <time.h> struct tm *gmtime(const time_t *time);
言語レベル: ANSI
スレッド・セーフ: いいえ。代わりに gmtime_r() を使用します。
説明
gmtime() 関数は、time 値を秒単位で分割し、<time.h> で定義された tm 構造体に保管します。 time の値は、通常、time() 関数を呼び出して取得します。
tm 構造体のフィールドには、以下のものがあります。
戻り値
gmtime() 関数は、結果である tm 構造体へポインターを戻します。
gmtime() の使用例
この例では、gmtime() 関数を使用して time_t 表記を協定世界時 (UTC) 文字ストリングへ調整し、次にそれを asctime() 関数を使用して出力可能なストリングに変換します。
#include <stdio.h> #include <time.h> int main(void) { time_t ltime; time(<ime); printf ("Coordinated Universal Time is %s\n", asctime(gmtime(<ime))); } /************************ Output should be similar to: ********** Coordinated Universal Time is Wed Aug 18 21:01:44 1993 */
関連情報