gmtime ライブラリ関数

時間値を構造体に変換する

struct tm *gmtime( const time_t *timer );


サンプルです。

#include <stdio.h>
#include <time.h>

int main()
{
        /* tm 型の構造体へのポインタを返す */
        struct tm *ptm;
        time_t tTime;

        time( &tTime );

        ptm = gmtime( &tTime );

        printf( "万国標準時 (UTC)\n" );
        printf( "年: %d年\n", ptm->tm_year +1900 );
        printf( "月: %d月\n", ptm->tm_mon+1 );
        printf( "日: %d日\n", ptm->tm_mday );
        return 0;
}

トップページ