fork(2) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <ctime>
  4.  
  5. std::string timeStampToHReadble(long timestamp)
  6. {
  7. const time_t rawtime = (const time_t)timestamp;
  8.  
  9. struct tm * dt;
  10. char timestr[30];
  11. char buffer [30];
  12.  
  13. dt = localtime(&rawtime);
  14. // use any strftime format spec here
  15. strftime(timestr, sizeof(timestr), "%m%d%H%M%y", dt);
  16. sprintf(buffer,"%s", timestr);
  17. std::string stdBuffer(buffer);
  18. return stdBuffer;
  19. }
  20.  
  21. int main() {
  22. std::cout << timeStampToHReadble(1356953890L) << "\n";
  23. }
  24.  
Success #stdin #stdout 0.02s 2812KB
stdin
Standard input is empty
stdout
1231113812