Advertisement
AbraaoAllysson

Data/Tempo formatado

Jun 16th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. using std::cout;
  3. using std::endl;
  4.  
  5. #include "string"
  6. using std::string;
  7.  
  8. #include <time.h>
  9. #include <sstream>
  10.  
  11.  
  12.  
  13. string nowTime(void)
  14. {
  15.     char nowTime[50];
  16.     time_t ttime=time(NULL);
  17.     tm *now=gmtime(&ttime);
  18.     strftime(nowTime, 50,"%c", now);
  19.     string str_time = (string) nowTime;
  20.    
  21.     return (str_time +" GMT");
  22. }
  23.  
  24.  
  25. int main()
  26. {
  27.    string strOut="Date: "; //Sun, 18 Oct 2012 10:36:20 GMT
  28.     cout<< (strOut+=nowTime())<<endl;
  29.    
  30.  
  31.    
  32.    
  33.  
  34.     return 0;
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement