_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
또는 구조체 __timeb32__timeb64 에 대한 포인터입니다_timeb.

반환 값

성공시 0, 실패시 오류 코드. timeptrNULL인 경우 반환 값은 EINVAL입니다.

설명

함수는 _ftime_s 현재 현지 시간을 가져오고 이 함수를 가리키는 timeptr구조에 저장합니다. 및 __timeb32__timeb64 구조체는 _timebSYS\Timeb.h에 정의됩니다. 구조체에는 다음 표에 나와 있는 4개 필드가 포함됩니다.

필드 설명
dstflag 현지 시간대에 현재 일광 절약 시간이 적용된 경우 0이 아닌 값. (일광 절약 시간을 결정하는 방법에 대한 설명은 참조 _tzset 하세요.)
millitm 1초 미만의 시간(밀리초)입니다.
time 1970년 1월 1일 자정(00:00:00)(UTC(협정 세계시)) 이후의 시간(초)입니다.
timezone 서쪽으로 이동할 경우 UTC와 현지 시간 사이의 차이(분)입니다. timezone 값은 전역 변수 _timezone 값에 따라 설정됩니다(_tzset 참조).

구조를 사용하는 __timeb64 함수는 _ftime64_s 파일 생성 날짜를 3000년 12월 31일 3000년 12월 31일 23:59:59까지 표현할 수 있지만 UTC _ftime32_s 는 2038년 1월 18일 23:59:59까지의 날짜만 나타냅니다. 1970년 1월 1일 자정은 이러한 모든 함수에 대한 날짜 범위의 하한입니다.

함수는 _ftime_s 정의_ftime64_s되지 않는 한 _USE_32BIT_TIME_T 64비트 시간을 포함하며_timeb, 이 경우 이전 동작이 적용 _ftime_s 됩니다. 32비트 시간을 _timeb 사용하고 32비트 시간을 포함합니다.

_ftime_s는 매개 변수의 유효성을 검사합니다. null 포인터를 전달 timeptr한 경우 함수는 매개 변수 유효성 검사에 설명된 대로 잘못된 매개 변수 처리기를 호출합니다. 계속해서 실행하도록 허용된 경우 함수가errnoEINVAL로 설정합니다.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 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>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

라이브러리

모든 버전의 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