The C date and time functions are a group of functions in the standard library of the C programming language implementing date and time manipulation operations.[1] They provide support for time acquisition, conversion between date formats, and formatted output to strings.

returns the current time of the system as a time_t value, number of seconds, (which is usually time since an epoch, typically the Unix epoch). The value of the epoch is operating system dependant, 1900 and 1970 are often used. See RFC 868.

#include<time.h>#include<stdlib.h>#include<stdio.h>intmain(void){time_tcurrent_time;char*c_time_string;/* Obtain current time. */current_time=time(NULL);if(current_time==((time_t)-1)){(void)fprintf(stderr,"Failure to obtain the current time.\n");exit(EXIT_FAILURE);}/* Convert to local time format. */c_time_string=ctime(&current_time);if(c_time_string==NULL){(void)fprintf(stderr,"Failure to convert the current time.\n");exit(EXIT_FAILURE);}/* Print to stdout. ctime() has already added a terminating newline character. */(void)printf("Current time is %s",c_time_string);exit(EXIT_SUCCESS);}