標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
ISO C |
両方 |
#include <time.h>
char *ctime(const time_t *timer);
#define _LARGE_TIME_API
#include <time.h>
char *ctime64 (const time64_t *timer);
timer が指すカレンダー時間から、文字ストリングの形式の現地時間に変換します。timer の値は、通常、time() 関数を呼び出して取得します。
ctime() 関数は、関数呼び出し asctime(localtime(timer)) と 等価です。
関数 ctime64() は、ctime() とまったく同じように動作しますが、2038 年 1 月 19 日の 03:14:07 UTC を超え 9999 年 12 月 31 日の 23:59:59 UTC までを限度とするカレンダー時間を指す、time64_t 値を変換できます。
"%.3s %.3s%3d %.2d:%.2d:%.2d %d¥n"
例えば、Mon Jul 16 02:03:55 1987¥n¥0
エラーが起こった場合、ctime() は値を戻しません。
TZ も _TZ も定義されない場合、時間帯情報について現行ロケールの値が照会されます。TZ も _TZ も定義されず、LC_TOD 時間帯情報が現行ロケールに存在しない場合、デフォルト値が現地時間に適用されます。POSIX プログラムでは単にデフォルトで協定世界時 (UTC) になりますが、非 POSIX プログラムでは、システム・クロックの設定に基づいて UTC からのオフセットを確立します。
現地時間を処理するための時間帯のカスタマイズについて詳しくは、「z/OS XL C/C++ プログラミング・ガイド」の『時間帯のカスタマイズ』を参照してください。
⁄* CELEBC33
This example polls the system clock by using the library
function &ttime..
It then prints a message giving the current date and time.
*⁄
#include <time.h>
#include <stdio.h>
int main(void)
{
time_t ltime;
time(<ime);
printf("the time is %s", ctime(<ime));
}
the time is Fri Jun 16 16:03:38 2006