How To Get Time And Date In C

[Solved] How To Get Time And Date In C | C - Code Explorer | yomemimo.com
Question : how to get time and date in c

Answered by : inquisitive-iguana-chtalxwyxl6t

#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\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
}

Source : https://stackoverflow.com/questions/1442116/how-to-get-the-date-and-time-values-in-a-c-program | Last Update : Thu, 23 Jun 22

Question : c get time

Answered by : julesg10

/* localtime example */
#include <stdio.h>
#include <time.h>
int main ()
{ time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); printf ( "Current local time and date: %s", asctime (timeinfo) ); return 0;
}

Source : https://stackoverflow.com/questions/5141960/get-the-current-time-in-c | Last Update : Thu, 21 Jan 21

Answers related to how to get time and date in c

Code Explorer Popular Question For C