_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
、、または__timeb64
構造体への_timeb
__timeb32
ポインター。
解説
この関数は _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 を参照してください)。 |
この _ftime64
構造体を __timeb64
使用する関数を使用すると、ファイルの作成日を UTC の 23:59:59、3000 年 12 月 31 日まで表現できます。一方 _ftime32
、UTC は 2038 年 1 月 18 日 23:59:59 までの日付のみを表します。 これらの関数の日付範囲の下限は、いずれも 1970 年 1 月 1 日の午前 0 時です。
この関数は_ftime
、定義されていない限り_USE_32BIT_TIME_T
、_timeb
64 ビット時刻を_ftime64
含みます。この場合、古い動作が有効_ftime
になります。32 ビット時刻が使用され、_timeb
32 ビット時刻が含まれます。
_ftime
はそのパラメーターを検証します。 null ポインターを渡timeptr
すと、「パラメーターの検証」で説明されているように、関数は無効なパラメーター ハンドラーを呼び出します。 実行の継続が許可された場合、関数は errno
を EINVAL
に設定します。
既定では、この関数のグローバル状態の適用対象は、アプリケーションになります。 この動作を変更するには、「CRT のグローバル状態」を参照してください。
必要条件
機能 | 必須ヘッダー |
---|---|
_ftime |
<sys/types.h> と <sys/timeb.h> |
_ftime32 |
<sys/types.h> と <sys/timeb.h> |
_ftime64 |
<sys/types.h> と <sys/timeb.h> |
互換性の詳細については、「 Compatibility」を参照してください。
例
// 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] );
}
Seconds since midnight, January 1, 1970 (UTC): 1051553334
Milliseconds: 230
Minutes between UTC and local time: 480
Daylight savings time flag (1 means Daylight time is in effect): 1
The time is Mon Apr 28 11:08:54.230 2003
関連項目
時間管理
asctime
, _wasctime
ctime
, _ctime32
, _ctime64
, _wctime
, _wctime32
, _wctime64
gmtime
, _gmtime32
, _gmtime64
localtime
, _localtime32
, _localtime64
time
, _time32
, _time64
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示