首页 > 学院 > 开发设计 > 正文

时间数值转换

2019-11-10 19:36:15
字体:
来源:转载
供稿:网友
通过当前时间来获取年月日 (年+1900, 月+1)time_t nowtime = time(NULL);tm* pTime = localtime(&nowtime);int nYear = pTime->tm_year +1900;int nMon = pTime->tm_mon +1;int nDay = pTime->tm_mday;int nHour = pTime->tm_hour;int nMin = pTime->tm_min;int nSec = pTime->tm_sec;// 通过自己填写日期来获得时间值struct tm t;time_t t_of_day;t.tm_year = 2016-1900; // 当前年-1900t.tm_mon = 3-1; // 当前月-1t.tm_mday = 14;t.tm_hour = 11;t.tm_min = 20;t.tm_sec = 12;t.tm_isdst = 0;t_of_day = mktime(&t);CCLog("nowtime = %lld, t_of_day = %lld", nowtime, t_of_day);CCLog(ctime(&t_of_day)); // 系统打印时间
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表