Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

how to get time and date in c

#include <stdio.h>
#include <time.h>

int main()
{
  time_t t = time(NULL);
  struct tm tm = *localtime(&t);
  printf("now: %d-%02d-%02d %02d:%02d:%02d
", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #time #date
ADD COMMENT
Topic
Name
2+8 =