_ftime、_ftime32、_ftime64

現在の時刻を取得します。これらの関数のセキュリティを強化したバージョンについては、「_ftime_s、_ftime32_s、_ftime64_s」を参照してください。

void _ftime( 
   struct _timeb *timeptr 
);
void _ftime32( 
   struct __timeb32 *timeptr 
);
void _ftime64( 
   struct __timeb64 *timeptr 
);

パラメーター

  • timeptr
    _timeb__timeb32 または __timeb64 構造体へのポインター。

解説

_ftime の関数は現在の現地時刻を受け取り timeptr が指す構造体に格納します _timeb__timeb32 と __timeb64 の構造は SYS \ Timeb.h で定義されます。これらは次の表に示す 4 種類のフィールドが含まれています。

  • dstflag
    夏時間がローカル タイム ゾーンに対して現在の場合は。夏時間を決定する方法を _tzset (詳細についてはを参照してください)。

  • millitm
    ミリ秒の小数部のほんの。

  • time
    時 (00:00 秒の時点以降に : 00) の 1970 年 1 月 1 日 1 の世界協定 (UTC) 時刻。

  • timezone
    UTC 時刻とローカル タイムでは西方に移動する場合の相違点。timezone の値がグローバル変数 _timezone の値のセット (_tzset を参照してください。

_ftime64 は __timeb64 構造を使用するを作成日 23:59 によって表されるを : 593000 12 年 1 月 31 日(UTC); _ftime32 が 03:14 だけで日付を表す場合 : 1 年 1 月 07 日 19 時 2038 の UTC。は1970 年が 1 年 1 月 1 日これらのすべての関数の日付範囲の下限はです。

_ftime は _ftime64 と同じです _timeb は 64 ビットの時刻が格納されます。これは以前の動作が有効な場合 _USE_32BIT_TIME_T が定義されている場合は; _ftime は 32 ビットの時刻を使用し_timeb は 32 ビットの時刻が格納されます。

_ftime はパラメーターを検証します。null ポインターの パラメーターの検証 に説明されているように timeptr として渡られたら関数無効なパラメーター ハンドラーを呼び出します。実行の継続が許可 EINVAL に関数を設定 errno。

必要条件

Function

必須ヘッダー

_ftime

<sys/types.h> および <sys/timeb.h>

_ftime32

<sys/types.h> および <sys/timeb.h>

_ftime64

<sys/types.h> および <sys/timeb.h>

互換性の詳細については、「C ランタイム ライブラリ」の「互換性」を参照してください。

使用例

// crt_ftime.c
// compile with: /W3
// This program uses _ftime to obtain the current
// time and then stores this time in timebuffer.

#include <stdio.h>
#include <sys/timeb.h>
#include <time.h>

int main( void )
{
   struct _timeb timebuffer;
   char timeline[26];
   errno_t err;
   time_t time1;
   unsigned short millitm1;
   short timezone1;
   short dstflag1;

   _ftime( &timebuffer ); // C4996
   // Note: _ftime is deprecated; consider using _ftime_s instead

   time1 = timebuffer.time;
   millitm1 = timebuffer.millitm;
   timezone1 = timebuffer.timezone;
   dstflag1 = timebuffer.dstflag;

   printf( "Seconds since midnight, January 1, 1970 (UTC): %I64d\n", 
   time1);
   printf( "Milliseconds: %d\n", millitm1);
   printf( "Minutes between UTC and local time: %d\n", timezone1);
   printf( "Daylight savings time flag (1 means Daylight time is in "
           "effect): %d\n", dstflag1); 
   
   err = ctime_s( timeline, 26, & ( timebuffer.time ) );
   if (err)
   {
       printf("Invalid argument to ctime_s. ");
   }
   printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm,
           &timeline[20] );
}
  

同等の .NET Framework 関数

System::DateTime::Now

参照

関連項目

時間管理

asctime、_wasctime

ctime、_ctime32、_ctime64、_wctime、_wctime32、_wctime64

gmtime、_gmtime32、_gmtime64

localtime、_localtime32、_localtime64

time、_time32、_time64