Linux编程(获取系统时间)

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

int main()
{

        time_t  now;
        struct  tm  *w;
        time(&now);
        w=localtime(&now);
        printf("%04d/%02d/%02d\n%02d:%02d:%02d\n",w->tm_year+1900,
                w->tm_mon+1,w->tm_mday,w->tm_hour,w->tm_min,w->tm_sec);

        return 0;
}

 

posted @ 2017-09-02 21:13  Dsp Tian  阅读(1237)  评论(0编辑  收藏  举报