Converts a time value to string in the same format as asctime.
char* ctime (const time_t * timer);
This function has the following parameter.
C string containing the date and time information in a human-readable format.
The resulting string has the following format: Www Mmm dd hh:mm:ss yyyy
#include <stdio.h> /* printf */
#include <time.h> /* time_t, time, ctime */
/* w w w . j a v a 2 s .c o m*/
int main ()
{
time_t rawtime;
time (&rawtime);
printf ("The current local time is: %s", ctime (&rawtime));
return 0;
}
The code above generates the following result.
#include <time.h>
#include <stdio.h>
int main(void)
{
time_t result = time(NULL);
printf("%s", ctime(&result));
}
The code above generates the following result.