Advertisement
jxsl13

Untitled

Aug 7th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. const std::string currentDateTime() {
  2. time_t currentTime;
  3. struct tm *localTime;
  4.  
  5. time( &currentTime ); // Get the current time
  6. localTime = localtime( &currentTime ); // Convert the current time to the local time
  7.  
  8. int Day = localTime->tm_mday;
  9. int Month = localTime->tm_mon + 1;
  10. int Year = localTime->tm_year + 1900;
  11. int Hour = localTime->tm_hour;
  12. int Min = localTime->tm_min;
  13. int Sec = localTime->tm_sec;
  14.  
  15. char timeBuf[512];
  16. str_format(timeBuf, sizeof(timeBuf), "%d:%d:%d %d.%d.%d", Hour, Min, Sec, Day, Month, Year);
  17.  
  18. return timeBuf;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement