[code]
int main(int argc, const char * argv[])
{
long secondsSince1970=time(NULL)+4000000;
long someTimeLater=secondsSince1970;
struct tm now;
localtime_r(&secondsSince1970, &now);
struct tm later;
localtime_r(&someTimeLater, &later);
// 현재시간출력
printf(“The current time was %d:%d:%d.n”,now.tm_hour, now.tm_min, now.tm_sec);
// 오늘 날짜출력
printf(“The current date was %.2d-%.2d-%.4d.n”,1+(now.tm_mon),now.tm_mday, (now.tm_year)+1900);
// 4만초 후의 날짜출력
printf(“The date in 4 million seconds will be %.2d-%.2d-%.2d,n”, (later.tm_mon)+1, later.tm_mday, (later.tm_year)+1900);
// 4만초 후의 시간출력
printf(“The time in 4 million seconds will be %d:%d:%d.n”, later.tm_hour, later.tm_min, later.tm_sec);
return 0;
}
[/code]
댓글