c++ - time since epoch to string using boost -


  स्वत: समयआसोपोक = बढ़ावा :: क्रोनो :: अवधि_कास्ट :: बढ़ावा :: chrono :: microseconds & gt; (बढ़ावा :: chrono :: steady_clock :: अब () time_since_epoch ()) गिनती ()।। बढ़ावा :: posix_time :: ptime अब (बढ़ावा :: ग्रेगोरीय :: दिनांक (1, 1, 1), बढ़ावा :: posix_time :: microsec (static_cast & lt; std :: int64_t> (timeSinceEpoch))); Std :: string str = boost :: posix_time :: to_iso_string (अब);  

आउटपुट: 19700114 टी 232422.133653 जो यह गलत है, मैं क्या कर रहा हूं?

कुछ सिस्टम पर, स्थिर_क्लॉक का युग बूट से नैनोसेकंड होता है।

# शामिल करें & lt; boost / date_time / gregorian / gregorian.hpp & gt; # शामिल करें & lt; boost / date_time / posix_time / posix_time.hpp & gt; # शामिल करें & lt; boost / chrono.hpp & gt; #include & lt; स्ट्रिंग & gt; # शामिल करें & lt; iostream & gt; Int main () {boost :: posix_time :: ptime const time_epoch (boost :: gregorian :: date (1970, 1, 1)); ऑटो एमएस = (बढ़ावा :: posix_time :: microsec_clock :: local_time () - time_epoch) .total_microseconds (); Std :: cout & lt; & lt; "माइक्रोजकंड्स": & lt; & lt; एमएस एंड एलटी; & lt; "\ N"; Boost :: posix_time :: ptime now = time_epoch + boost :: posix_time :: microseconds (एमएस); Std :: cout & lt; & lt; को बढ़ावा देने :: posix_time :: to_iso_string (अब); }

प्रिंट

  microseconds: 1415115992000000 20141104T154632  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -