boost当前时间格式化为YYYYMMDDHHMMSS

#include <boost/date_time/posix_time/posix_time.hpp>
std::string strTime = boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time());
//这时候strTime里存放时间的格式是YYYYMMDDTHHMMSS,日期和时间用大写字母T隔开了  
int pos = strTime.find('T');
strTime.replace(pos, 1, std::string(""));
printf("%s\n", strTime.c_str());

输出:


猜你喜欢

转载自blog.csdn.net/tong5956/article/details/79377244