지정 한 날 짜 를 초 로 변환 합 니 다.
필요 한 데이터 형식: timet,struct tm
필요 함수: timet mktime(struct tm * timeptr);
대상: 지 정 된 날 짜 를 1970.1.1 에서 지나 간 초 로 변환 합 니 다.
과정: tm 데이터 구 조 를 작성 하고 함수 에 전송 하여 time 를 되 돌려 줍 니 다.t 의 결과.
다음은 msdn 이 mktime 함수 에 대한 설명 입 니 다.
time_t mktime(
struct tm *timeptr
);
__time32_t _mktime32(
struct tm *timeptr
);
__time64_t _mktime64(
struct tm *timeptr
);
_mktime32 returns the specified calendar time encoded as a value of type time_t. If timeptr references a date before midnight, January 1, 1970, or if the calendar time cannot be represented, _mktime32 returns –1 cast to type time_t. When using _mktime32 and if timeptr references a date after 03:14:07 January 19, 2038, Coordinated Universal Time (UTC), it will return –1 cast to type time_t.
_mktime64 will return –1 cast to type __time64_t if timeptr references a date after 23:59:59, December 31, 3000, UTC.
다음은 실례 입 니 다.
#include
#include
int main( void ){
struct tm when;
__time64_t now, result; int days;
char buff[80]; time( &now );
_localtime64_s( &when, &now );
asctime_s( buff, sizeof(buff), &when );
printf( "Current time is %s", buff );
days = 20;
when.tm_mday = when.tm_mday + days;
if( (result = mktime( &when )) != (time_t)-1 ) {
asctime_s( buff, sizeof(buff), &when );
printf( "In %d days the time will be %s", days, buff );
} else perror( "mktime failed" );
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.