whisht

    十年

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
#include <sys/time.h>
#include <sys/types.h>
#include <linux/rtc.h>
#include <time.h>

char ss[200]
time_t timep;
struct tm *p;
time(&timep);
p=localtime(&timep); /*取得当地时间*/
sprintf(ss, "%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d", (1900+p->tm_year),(1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
printf("%s\n", ss);


输入结果:20120601015012


 

posted on 2012-06-01 00:47  WHISHT  阅读(1306)  评论(0编辑  收藏  举报