_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
    現在、現地のタイム ゾーンで夏時間が有効な場合は 0 以外の値。 夏時間の設定方法の詳細については、「_tzset」を参照してください。

  • millitm
    秒の小数部 (ミリ秒単位)

  • time
    世界協定時刻 (UTC: Coordinated Universal Time) の 1970 年 1 月 1 日の 00:00:00 から経過した時間

  • timezone
    UTC と現地時刻との差 (西回り、分単位)。 timezone の値は、_timezone グローバル変数の値から設定されます (_tzset に関するトピックを参照)。

__timeb64 構造体を使用する _ftime64 は、UTC の 3000 年 12 月 31 日の 23 時 59 分 59 秒までのファイル作成日を表すことができます。それに対して、_ftime32 は、UTC の 2038 年 1 月 19 日の 03 時 14 分 07 秒までしか表すことができません。 これらの関数の日付範囲の下限は、すべて 1970 年 1 月 1 日の午前零時です。

_ftime相当する_ftime64と_timeb、64 ビットの時刻が含まれています。 _USE_32BIT_TIME_T が定義されない限り、これが当てはまります。_USE_32BIT_TIME_T を定義した場合は、以前の動作が有効です。つまり、_ftime は 32 ビットの時刻を使用し、_timeb には 32 ビットの時刻が格納されます。

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

必要条件

機能

必須ヘッダー

_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