c++ - how to display system current time + 3 minutes? -


C ++:

  • How can I show the system current time (Only without time)?

  • How can I show current time + 3 minutes?

  • Can I use it for cout ?

Which library or function to use?

You can try this example (use c ++ 11 clang 3.6): < / P>

  #include & lt; Iostream & gt; # Include & lt; Iomanip & gt; # Include & lt; Ctime & gt; # Include & lt; Chrono & gt; Int main () {std :: chrono :: system_clock :: time_point now = std :: chrono :: system_clock :: now (); Std :: time_t now_c = std :: chrono :: system_clock :: to_time_t (now - std :: chrono :: hours (24)); Std :: cout & lt; & Lt; Std :: put_time (std :: local time (& amp; now_c), "% T") & lt; & Lt; Std :: endl; Std :: time_t later_c = std :: chrono :: system_clock :: to_time_t (now - std :: chrono :: hours (24) + std :: chrono :: minutes (3)); Std :: cout & lt; & Lt; Std :: put_time (std: local time (& amp; later_c), "% T") & lt; & Lt; Std :: endl; Return 0; }  

Just use std :: chrono .


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -