Syntax
#include <time.h> time_t time(time_t *timeptr);Description
time determines the current calendar time, which is not necessarily the local time localtime.
Note: The time and date functions begin at 00:00:00 Universal Time, January 1, 1970.
time returns the current calendar time. The return value is also stored in the location given by timeptr. If timeptr is NULL, the return value is not stored. If the calendar time is not available, the value (time_t)(-1) is returned.
This example gets the time and assigns it to ltime. ctime then converts the number of seconds to the current date and time. This example then prints a message giving the current time.
#include <time.h> #include <stdio.h> int main(void) { time_t ltime; time(<ime); printf("The time is %s\n", ctime(<ime)); return 0; /**************************************************************************** The output should be similar to: The time is Thu Jan 12 11:38:37 1995 ****************************************************************************/ }Related Information