c print current time code example
Example 1: c program to print current date and time
int main()
{
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
time_t t; // not a primitive datatype
time(&t);
printf("\nThis program has been writeen at (date and time): %s", ctime(&t));
printf("\n\n\t\t\tCoding is Fun !\n\n\n");
return 0;
}
Example 2: c get time
/* localtime example */
int main ()
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "Current local time and date: %s", asctime (timeinfo) );
return 0;
}