C
[C] 169 날짜 및 시간 구하기 localitme()
qkrwngus
2021. 2. 2. 20:46
Desc :
struct tm *localtime( const time_t *timer );
struct tm 구조체 타입의 주소값을 반환
Source Code :
#include <stdio.h>
#include <time.h>
void main()
{
time_t now;
struct tm t;
time(&now);
t = *localtime(&now); // struct tm 구조체의 포인터의 값을 반환한다.
printf("현재 날짜 및 시간 : %4d년 %d월 %d일 %d:%d:%d\n"
, t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
}
Result :