fork download
  1. #include <time.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main() {
  6. tm tmbuf;
  7. const char *str = "20:48:01.469 UTC MAR 31 2016";
  8. const char *fmt = "%H:%M:%S.%Y %Z %b %d %Y";
  9. strptime(str,fmt,&tmbuf);
  10. cout << tmbuf.tm_year+1900 <<"-"<<tmbuf.tm_mon+1<<"-"<<tmbuf.tm_mday<<" ";
  11. cout << tmbuf.tm_hour <<":"<<tmbuf.tm_min<<":"<<tmbuf.tm_sec<<endl;
  12. return 0;
  13. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
2016-3-31 20:48:1