#navi(../)
* UNIX時間(time_t)を取得する・time [#c3a8c550]
time関数を使用してUNIX時間(time_t)の値を取得するC言語サンプルコードを以下に記します。
#contents
#htmlinsertpcsp(c-top.html,c-sp.html)
*関連記事 [#oad97bb6]
-[[時間や日時を書式に従って整形する・strftime>日時/時間や日時を書式に従って整形する・strftime]]
-[[曜日を取得するCサンプルコード>日時/曜日を取得するCサンプルコード]]
-[[UNIX時間(time_t)を取得する・time>日時/UNIX時間(time_t)を取得する・time]]
-[[UNIX時間(time_t)を文字列の日時に変換する・time, localtime>日時/UNIX時間(time_t)を文字列の日時に変換する・time, localtime]]
-[[世界協定時(UTC)を取得する・gmtime>日時/世界協定時(UTC)を取得する・gmtime]]
* UNIX時間(time_t)を取得するC言語サンプルコード [#x2f9f513]
time関数を使用したC言語サンプルコードを以下に記します。
&ref(time.c); (改行コードLF)
#include <stdio.h>
#include <time.h>
int main(void)
{
printf("time_t : %d\n", time(NULL));
return 0;
}
サンプルコードをコンパイルし実行した結果を以下に記します。
$ gcc time.c -o time
$ ./time
time_t : 1406384487
以上、time関数を使用しUNIX時間を取得するC言語サンプルコードでした。
#htmlinsertpcsp(c-btm.html,c-sp.html)