首页 > 其他 > 详细

字符串转日期

时间:2014-05-14 21:51:43      阅读:413      评论:0      收藏:0      [点我收藏+]
//Processing date
    struct tm time;
std::string date;
char dateBuff[128] = {0};
time.tm_year = atoi(md_date.getString().substr(0,4).c_str()) - 1900;
time.tm_mon =  atoi(md_date.getString().substr(4,2).c_str()) - 1;
time.tm_mday = atoi(md_date.getString().substr(6,2).c_str()) ;
time.tm_hour = atoi(md_time.getString().substr(0,2).c_str()) ;
time.tm_min =  atoi(md_time.getString().substr(3,2).c_str());
time.tm_sec =  atoi(md_time.getString().substr(6,2).c_str());
std::string mmin =  md_time.getString().substr(9,3);
time_t secs = mktime(&time);
secs += 8*60*60;
struct tm *md_localtime = localtime(&secs);
sprintf(dateBuff, "%02d%02d%02d%02d%02d", md_localtime->tm_mon+1, md_localtime->tm_mday, md_localtime->tm_hour, md_localtime->tm_min, md_localtime->tm_sec);
dateStream << md_localtime->tm_year+1900 << dateBuff << mmin ;
dateStream >> date;

字符串转日期,布布扣,bubuko.com

字符串转日期

原文:http://blog.csdn.net/ctxbloger/article/details/25816631

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!