Advertisement
dimipan80

Current Date and Time

Oct 17th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. /*
  2.  * Create a console application that prints the current date and time.
  3.  * (15 September 2015 16:25:17)
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <time.h>
  8.  
  9. int main()
  10. {
  11.     time_t t = time(NULL);
  12.     struct tm tm = *localtime(&t);
  13.     char* arrMonthNames[12] = {"January", "February", "March", "April", "May", "June", "July",
  14.         "August", "September", "October", "November", "December"};
  15.  
  16.     printf("Current Date and Time is: %02d %s %d %02d:%02d:%02d\n",
  17.             tm.tm_mday, arrMonthNames[tm.tm_mon], tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
  18.  
  19.     return (0);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement