fork download
  1. #include <iostream>
  2. #include <ctime> // ******* C++ header for std::gmtime() etc.
  3.  
  4. int main()
  5. {
  6. std::time_t now = std::time(nullptr) ;
  7.  
  8. // make a copy of the std::tm
  9. std::tm modified_time = *std::gmtime( &now ) ;
  10.  
  11. // modify the copy as you please
  12. modified_time.tm_sec = 0 ; // set seconds to zero
  13. modified_time.tm_year += 6 ; // move to six years later
  14. // etc...
  15.  
  16. std::cout << "UTC: " << std::asctime( &modified_time ) ;
  17. }
  18.  
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
UTC: Sat Jun 22 07:50:00 2019