名前空間
変種
操作

time_t

提供: cppreference.com
< c‎ | chrono
ヘッダ <time.h> で定義
typedef/* unspecified */ time_t;

時刻を表現可能な算術(C11未満)実数(C11以上)型。

C 標準では定義されていませんが、これは、ほとんど必ず、 POSIX 時間と一致する、協定世界時1970年1月1日0時0分からの秒数 (閏秒を含まない) を保持する整数値です。

目次

[編集]ノート

標準は time_t 型の値に言及するときに用語 calendar time を使用します。

[編集]

エポックの開始を表示します。

#include <stdio.h>#include <time.h>#include <stdint.h>   int main(void){ time_t epoch =0;printf("%jd seconds since the epoch began\n", (intmax_t)epoch);printf("%s", asctime(gmtime(&epoch)));}

出力例:

0 seconds since the epoch began Thu Jan 1 00:00:00 1970

[編集]参考文献

  • C11 standard (ISO/IEC 9899:2011):
  • 7.27.1/3 Components of time (p: 388)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.23.1/3 Components of time (p: 338)
  • C89/C90 standard (ISO/IEC 9899:1990):
  • 4.12.1 Components of time

[編集]関連項目

エポックからの経過時間で表したシステムの現在時刻を返します
(関数)[edit]
エポックからの経過時間を現地時間で表したカレンダー時刻に変換します
(関数)[edit]
エポックからの経過時間を協定世界時 (UTC) として表したカレンダー時刻に変換します
(関数)[edit]
close