2010-04-18 202 views

回答

9

你需要時間先添加一個時間對象,然後將它輸出這樣的:

boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%Y%m%d %H:%M:%S.%f"); 
std::stringstream date_stream; 
date_stream.imbue(std::locale(date_stream.getloc(), facet)); 
date_stream << boost::posix_time::microsec_clock::universal_time(); 

輸出:

20100326 12:02:08.024820

測試升壓1.41

+0

這將輸出微秒,而不是毫秒。 – Gabor 2016-06-10 13:14:53

相關問題