fork(3) download
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <sstream>
  5.  
  6. int main(int argc, char *argv[]) {
  7. std::string d_time = "2017-09-25 12:23:10";
  8.  
  9. // Get TM structure
  10. std::istringstream time_stream{d_time};
  11. std::tm time;
  12. time_stream >> std::get_time(&time, "%Y-%m-%d %H:%M:%S");
  13.  
  14. // Print
  15. std::cout << "H: " << std::put_time(&time, "%H\n");
  16. std::cout << "M: " << std::put_time(&time, "%M\n");
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
H: 12
M: 23