fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. int main(void) {
  5. char dt[20]; // space enough for DD/MM/YYYY HH:MM:SS and terminator
  6. struct tm tm;
  7. time_t current_time;
  8.  
  9. current_time = time(NULL);
  10. tm = *localtime(&current_time); // convert time_t to struct tm
  11. strftime(dt, sizeof dt, "%d/%m/%Y %H:%M:%S", &tm); // format
  12.  
  13. printf("%ld ==> %s\n", (long)current_time, dt);
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 2184KB
stdin
Standard input is empty
stdout
1428595417 ==> 09/04/2015 16:03:37