#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());
输出: