トップページ > キーワード検索 > tm
C言語規格
C言語(その他)
プログラム
その他
tm
機能 歴時刻の要素(詳細時刻)を保持する型。
定義 #include <time.h>

struct tm

tm構造体は以下のメンバを含む。
メンバ名意味
inttm_sec秒(0〜60)
inttm_min分(0〜59)
inttm_hour時(0〜23)
inttm_mday日(1〜31)
inttm_mon1月からの月数(0〜11)
inttm_year1900年からの年数
inttm_wday日曜日からの日数(0〜6)
inttm_yday1月1日からの日数(0〜365)
inttm_isdst夏時間フラグ
実装例
#include <time.h>
#include <stdio.h>

int main(void)
{
    struct tm *tp;
    time_t t;
    
    time(&t);
    
    tp = localtime(&t);
    
    printf("%d/%d/%d %02d:%02d:%02d\n",
       (tp->tm_year + 1900),
       (tp->tm_mon + 1),
       tp->tm_mday,
       tp->tm_hour,
       tp->tm_min,
       tp->tm_sec);
    
    return 0;
}
実行結果
2014/5/3 12:00:15





inserted by FC2 system