fork(3) download
  1. #include <iostream>
  2. #include <string>
  3. #include <ctime>
  4.  
  5.  
  6. int main()
  7. {
  8. const std::string s = "20160907-05:00:54.123";
  9.  
  10. tm t;
  11. t.tm_year = stoi(s.substr(0, 4));
  12. t.tm_mon = stoi(s.substr(4, 2));
  13. t.tm_mon = stoi(s.substr(4, 2));
  14. t.tm_mday = stoi(s.substr(6, 2));
  15. t.tm_hour = stoi(s.substr(9, 2));
  16. t.tm_min = stoi(s.substr(12, 2));
  17. t.tm_sec = 0;
  18. double sec = stod(s.substr(15));
  19. std::cout << mktime(&t) + sec * 1000;
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
54122