Advertisement
bhuvanchandradv

get data and time example in C

Feb 7th, 2021
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. int main()
  5. {
  6.   time_t t = time(NULL);
  7.   struct tm tm = *localtime(&t);
  8.   printf("now: %d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement