Advertisement
DrAungWinHtut

timetest.c

Dec 18th, 2022
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. int main()
  5. {
  6.     time_t current_time=NULL;  
  7.     struct tm time_info;
  8.     char time_string[100];
  9.  
  10.     // Get the current time
  11.     time(&current_time);
  12.  
  13.     // Convert the time to a local time representation
  14.      localtime_s(&time_info ,&current_time);
  15.  
  16.     // Format the time as a string
  17.     strftime(time_string, sizeof(time_string), "%c", &time_info);
  18.     //yyyymmddhhmmss.dmp
  19.     // Print the time string
  20.     printf("The current date and time is: %s\n", time_string);
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement