fork download
  1. #include <iostream>
  2. #include <chrono>
  3. using namespace std;
  4.  
  5. int main()
  6.  
  7. {
  8.  
  9. auto tt = chrono::system_clock::to_time_t(chrono::system_clock::now());
  10. struct tm* ptm = localtime(&tt);
  11. char date[60] = { 0 };
  12. sprintf(date, "%d-%02d-%02d", (int)ptm->tm_year + 1900, (int)ptm->tm_mon + 1, (int)ptm->tm_mday+21);
  13. string d = date;
  14.  
  15. std::cout << d.c_str() << std::endl;
  16.  
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 4568KB
stdin
Standard input is empty
stdout
2019-11-37