fork download
  1. #include <iostream>
  2. #include <sys/time.h>
  3. using namespace std;
  4.  
  5. #include <string>
  6.  
  7. int main() {
  8. timeval curTime;
  9. gettimeofday(&curTime, NULL);
  10. int milli = curTime.tv_usec / 1000;
  11.  
  12. char buffer [80];
  13. strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", localtime(&curTime.tv_sec));
  14.  
  15. char currentTime[84] = "";
  16. sprintf(currentTime, "%s:%03d", buffer, milli);
  17. printf("current time: %s \n", currentTime);
  18. return 0;
  19. }
Success #stdin #stdout 0s 4440KB
stdin
Standard input is empty
stdout
current time: 2020-02-27 00:26:47:072