Chinaunix首页 | 论坛 | 博客
  • 博客访问: 129539
  • 博文数量: 44
  • 博客积分: 956
  • 博客等级: 准尉
  • 技术积分: 521
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-18 12:45
文章分类
文章存档

2012年(11)

2011年(33)

分类: C/C++

2011-12-29 18:42:00

struct tm {
               int tm_sec;         /* seconds */
               int tm_min;         /* minutes */
               int tm_hour;        /* hours */
               int tm_mday;        /* day of the month , in the range 1 to 31*/
               int tm_mon;         /* month,in the range 0 to 11 */
               int tm_year;        /* year since 1900 */
               int tm_wday;        /* day of the week, in the range 0 to 6*/
               int tm_yday;        /* day in the year , in the range 0 to 365*/
               int tm_isdst;       /* daylight saving time */
           };
常用方发:
  1. time_t t = time(NULL);
  2. struct tm *tt = localtime(&t);

time(NULL)函数获取从1970-1-1 0:00到现在所经历的秒数,可以time(&t),而不获取返回值

localtime(&t)函数将该时间按转化为本地时间,存放在struct tm结构体中,返回该结构体的指针。

通过返回的指针来获取相应的时间项~

阅读(1878) | 评论(0) | 转发(0) |
0

上一篇:文件IO(17)

下一篇:struct stat

给主人留下些什么吧!~~