Programing - C/C Basic grammar
132 날짜 및 시간을 형식화( strftime )
junmoyo
2018. 5. 13. 21:28
개념 :
1. 원형 : size_t strftime(char *strDest, size_t maxsize, const char *format, const struct tm *timeptr)
소스코드:
#include<stdio.h>
#include<time.h>
int main(void)
{
time_t now;
struct tm t;
char buff[100];
now = time(NULL);
t = *localtime(&now);
strftime(buff, sizeof(buff), "%Y-%m-%d %I : %M : %S %p", &t);
puts(buff);
system("pause");
return 0;
}
결과: