_ftime_s
, _ftime32_s
, _ftime64_s
現在の時刻を取得します。 これらの関数は、CRT の_ftime
_ftime64
_ftime32
セキュリティ機能の説明に従ってセキュリティが強化されたバージョンのバージョンです。
構文
errno_t _ftime_s( struct _timeb *timeptr );
errno_t _ftime32_s( struct __timeb32 *timeptr );
errno_t _ftime64_s( struct __timeb64 *timeptr );
パラメーター
timeptr
、、または__timeb64
構造体への_timeb
__timeb32
ポインター。
戻り値
正常終了した場合は 0 を返します。失敗した場合はエラー コードを返します。 timeptr
が NULL
の場合、戻り値は EINVAL
です。
解説
この関数は _ftime_s
、現在の現地時刻を取得し、それが指す構造体に 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_s
構造体を __timeb64
使用する関数を使用すると、ファイルの作成日を UTC の 23:59:59、3000 年 12 月 31 日まで表現できます。一方 _ftime32_s
、UTC は 2038 年 1 月 18 日 23:59:59 までの日付のみを表します。 これらの関数の日付範囲の下限は、いずれも 1970 年 1 月 1 日の午前 0 時です。
この関数は_ftime_s
、定義されていない限り_USE_32BIT_TIME_T
、_timeb
64 ビット時刻を_ftime64_s
含みますが、その場合は古い動作が有効_ftime_s
です。32 ビット時刻を使用し、_timeb
32 ビット時刻を含みます。
_ftime_s
はそのパラメーターを検証します。 null ポインターを渡timeptr
すと、「パラメーターの検証」で説明されているように、関数は無効なパラメーター ハンドラーを呼び出します。 実行の継続が許可された場合、関数は errno
を EINVAL
に設定します。
既定では、この関数のグローバル状態の適用対象は、アプリケーションになります。 この動作を変更するには、「CRT のグローバル状態」を参照してください。
必要条件
機能 | 必須ヘッダー |
---|---|
_ftime_s |
<sys/types.h> と <sys/timeb.h> |
_ftime32_s |
<sys/types.h> と <sys/timeb.h> |
_ftime64_s |
<sys/types.h> と <sys/timeb.h> |
互換性の詳細については、「 Compatibility」を参照してください。
ライブラリ
C ランタイム ライブラリのすべてのバージョン。
例
// crt_ftime64_s.c
// This program uses _ftime64_s 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;
_ftime64_s( &timebuffer );
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 を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示