| cppreference.com -> 標準 C 時間 & 日付関数 -> 詳細 |
#include <time.h> char *asctime( const struct tm *時間 ); |
asctime()は時間 構造体で示された時間を以下のフォーマットの文字列に変換する:
曜日 月 日 時間:分:秒 年\n\0
サンプル:
Mon Jun 26 12:03:53 2000
関連トピック:#include <time.h> clock_t clock( void ); |
clock()関数はプログラムの実行を開始してからのプロセッサ時間を返す関数である。得られなかった場合には-1を返す。プロセッサ時間を秒に直すにはCLOCKS_PER_SECONDマクロでこの関数の返値を割ればよい。POSIX準拠のコンパイラであれば、CLOCKS_PER_SECONDの値は常に1,000,000である。
関連トピック:#include <time.h> char *ctime( const time_t *時間 ); |
ctime()はカレンダー時間の時間 を以下のフォーマットの文字列に変換する:
曜日 月 日 時間:分:秒 年\n\0
ctime()は以下の関数呼び出しと同じである
asctime( localtime( tp ) );
関連トピック:#include <time.h> double difftime( time_t 時間2, time_t 時間1 ); |
difftime()は時間2 - 時間1 という計算を秒のオーダーで求める関数である。
関連トピック:#include <time.h> struct tm *gmtime( const time_t *時間 ); |
gmtime()は与えられたグリニッジ標準時刻の時間 を返す関数である。サポートされていない場合にはNULLを返す。 警告!
関連トピック:#include <time.h> struct tm *localtime( const time_t *時間 ); |
localtime()はカレンダー時間の時間 をローカル時間に変換する。 警告!
関連トピック:#include <time.h> time_t mktime( struct tm *時間 ); |
mktime()はローカルタイムの時間 をカレンダー時間に変換して返す関数である。エラーがあった場合には-1が返る。
関連トピック:#include <time.h> size_t strftime( char *文字列バッファ, size_t 最大長, const char *フォーマット, struct tm *時間 ); |
strftime()は時間 の時間、日時情報を、フォーマット で指定されたフォーマットに従って変換し、文字列バッファ に格納する。文字列バッファの大きさを長さ で指定する。フォーマット に指定する特別な文字は以下の通りである:
| コード | 意味 |
| %a | abbreviated weekday name |
| %A | full weekday name |
| %b | abbreviated month name |
| %B | full month name |
| %c | the standard date and time string |
| %d | day of the month, as a number (1-31) |
| %H | hour, 24 hour format (0-23) |
| %I | hour, 12 hour format (1-12) |
| %j | day of the year, as a number (1-366) |
| %m | month as a number (1-12). Note: some versions of Microsoft Visual C++ may use values that range from 0-11. |
| %M | minute as a number (0-59) |
| %p | locale's equivalent of AM or PM |
| %S | second as a number (0-59) |
| %U | week of the year, sunday as the first day |
| %w | weekday as a decimal (0-6, sunday=0) |
| %W | week of the year, monday as the first day |
| %x | standard date string |
| %X | standard time string |
| %y | year in decimal, without the century (0-99) |
| %Y | year in decimal, with the century |
| %Z | time zone name |
| %% | a percent sign |
strftime()関数は文字列バッファ に書き込んだ文字数を返す。エラーが発生した場合にはゼロを返す。
関連トピック:#include <time.h> time_t time( time_t *time ); |
time()は現在の時間を返す関数である。エラーが発生した場合には-1が返される。引数の時間 が与えられた場合には、現在の時刻が時間 に格納される。
関連トピック: