반응형
tm *localtime(const time_t *time_pretr);
localtime() 함수는 <time.h> 헤더파일을 포함하여 사용할 수 있으며,
time_t 자료형 데이터의 포인터를 인자로 가진다.
그리고 struct tm 구조체 형태의 포인터로 반환해준다.
localtime()은 지역시간을 표현한다.
#include <iostream>
#include <time.h>
int main(){
using namespace std;
time_t currentTime;
currentTime = time(NULL);
tm *local = localtime(¤tTime);
cout << "Current Time: " << local->tm_hour << ":" << local->tm_min << ":" << local->tm_sec;
return 0;
}
반응형
'C++' 카테고리의 다른 글
[C++] std::ios_base::sync_with_stdio(false); (0) | 2020.05.05 |
---|---|
[C++] struct tm {}; (0) | 2020.03.29 |
[C++] STL std::sort(begin, end, compareFunction) (0) | 2020.03.07 |
[C++] STL std::pair() (0) | 2020.03.07 |
[C++] STL std::vector() (0) | 2020.03.07 |