ブーストシステム時刻のフォーマット文字列

ヘッダ

書式#include <ブースト/ DATE_TIME / posix_time / posix_time.hpp>


コード

 std ::文字列strDateTime =ブースト:: posix_time :: to_simple_string(ブースト:: posix_time :: microsec_clock :: LOCAL_TIME());

結果:2020-JAN-07 02:54:29.985437


 std ::文字列strTime =ブースト:: posix_time :: to_iso_string(ブースト:: posix_time :: microsec_clock :: LOCAL_TIME());
 strTime.insert(4 " - ")。
 strTime.insert(7、 " - ")。
 INT POS = strTime.find( 'T')。
 strTime.replace(POS、1、STD ::文字列(」「));
 strTime.insert(13、 ":")。
 strTime.insert(16、 ":");

 結果:2020-01-0710:54:29.976652

おすすめ

転載: blog.51cto.com/fengyuzaitu/2464889