Desc :
Source Code :
#include <stdio.h>
#include <time.h>
void main()
{
time_t now;
struct tm t;
char buff[100],AMPM[10];
now = time(NULL);
t = *localtime(&now);
strftime(buff, sizeof(buff), "%Y-%m-%d %H:%M:%S", &t);
strftime(AMPM, sizeof(AMPM), "%p", &t);
if (strcmp(AMPM, "AM")) strcpy(AMPM, " 오후"); // 일치하면 0 --> 실행 X
else strcpy(AMPM, " 오전");
strcat(buff, AMPM);
puts(buff);
}
Result :
'C' 카테고리의 다른 글
[C] 261 문자열로 된 날짜를 struct tm형식으로 변환 (0) | 2021.02.09 |
---|---|
[C] 260 문자열로 된 날짜를 time_t형식으로 변환 (0) | 2021.02.09 |
[C] 257 오늘의 요일 (0) | 2021.02.09 |
[C] 256 올해의 경과된 주의 수 (0) | 2021.02.09 |
[C] 255 올해의 경과된 날짜 수 (0) | 2021.02.09 |