출처 : http://sugame.tistory.com/101


// 현재 날짜와 시간
#include <time.h>
#include <stdio.h>

void main( void )
{
time_t now;
struct tm t;

time( &now );

t = *gmtime( &now );

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 );

getchar();
}


#include <time.h>
#include
<stdio.h>

void 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 );

getchar();
}

// 현재 날자에서 100일을 더한 날짜

#include <time.h>
#include
<stdio.h>

void main( void )
{
time_t now;
struct tm t;

time( &now );
t = *localtime( &now );
t.tm_mday += 100;
mktime( &t );

printf( "현재 날짜에 100일 더한 날짜 : %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 );

getchar();
}








태그 : c,date,TIME