牵着老婆满街逛

严以律己,宽以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

获取 struct tm中的正确时间

年份需要加上1900,貌似得到的值只是求得了从 1900经历了多少年....
然后月份需要加上1,这个是为什么,我忘记了=.=

#include <time.h>
time_t tval;
struct tm *now;        
time(
&tval);
now 
= localtime(&tval);
const int& day = now->tm_mday; //获得几号
const int year = now->tm_year + 1900//获取年份 
const int month = now->tm_mon + 1//获取当前月份
const int& hour = now->tm_hour; //获取当前为几时
const int& minu = now->tm_min; //获取分钟
const int& sec = now->tm_sec;//

posted on 2007-07-22 21:07 杨粼波 阅读(1543) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理