c 언어 현재 시간 가 져 오기

1137 단어 cstruct언어.include
#include <stdio.h>
#include <time.h>  

void main ()
{
time_t rawtime;
struct tm * timeinfo;

time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "\007The current date/time is: %s", asctime (timeinfo) );
char CruuentTime[50];
  strftime(CruuentTime, 24, "%Y-%m-%d %H:%M:%S", timeinfo);//     
printf(CruuentTime);
exit(0);
}

=================
#include <time.h>  --           
time_t --     (time.h   )
struct tm --     ,time.h     :
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
 
time ( &rawtime ); --     ,   , 1970 1     ,  rawtime
localtime ( &rawtime ); --       ,tm     
asctime ()--     ASCII    :
        : :   
=========================================
          :
 printf ( "%4d-%02d-%02d %02d:%02d:%02d
",1900+timeinfo->tm_year, 1+timeinfo->tm_mon, timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec); tm,tm_year 1900 , 1900, tm_mon, 0 , 1 。

좋은 웹페이지 즐겨찾기