头文件

#include


代码

 std::string strDateTime = boost::posix_time::to_simple_string(boost::posix_time::microsec_clock::local_time());

结果:2020-Jan-07 02:54:29.985437


 std::string strTime = boost::posix_time::to_iso_string(boost::posix_time::microsec_clock::local_time());
 strTime.insert(4, "-");
 strTime.insert(7, "-");
 int pos = strTime.find('T');
 strTime.replace(pos, 1, std::string(" "));
 strTime.insert(13, ":");
 strTime.insert(16, ":");

 结果:2020-01-07 10:54:29.976652