Desc :
확장 시간 구조체 struct _timeb
tb.millitm ,,,
기본 시간 구조체 struct tm t
Source Code :
#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>
void main()
{
struct _timeb tb;
struct tm t;
char buff[100];
_ftime(&tb);
t = *localtime(&tb.time);
printf("%4d-%d-%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,tb.millitm);
printf(ctime(&tb.time));
printf(asctime(&t));
puts(_strdate(buff));
puts(_strtime(buff));
strftime(buff, sizeof(buff), "%Y-%m-%d %H:%M:%S %p(%a)", &t);
puts(buff);
strftime(buff, sizeof(buff), "%#Y-%#m-%#d %#H:%#M:%#S %p(%a)", &t);
puts(buff);
strftime(buff, sizeof(buff), "%c", &t);
puts(buff);
strftime(buff, sizeof(buff), "%x %X", &t);
puts(buff);
strftime(buff, sizeof(buff), "%#c", &t);
puts(buff);
strftime(buff, sizeof(buff), "%#x", &t);
puts(buff);
}
Result :
'C' 카테고리의 다른 글
[C] 264 스택구현 (0) | 2021.02.17 |
---|---|
[C] 263 야구게임 (1) | 2021.02.17 |
[C] 261 문자열로 된 날짜를 struct tm형식으로 변환 (0) | 2021.02.09 |
[C] 260 문자열로 된 날짜를 time_t형식으로 변환 (0) | 2021.02.09 |
[C] 258 오전/오후 표시하기 strftime (0) | 2021.02.09 |