Converts the time structure to a character string.
Include
<time.h>
Prototype
char *asctime(const struct tm *tptr);
Argument
tptr
Return Value
Returns a pointer to a character string of the following format:
DDD MMM dd hh:mm:ss YYYY
DDD
is day of the week
MMM
is month of the year
dd
is day of the month
hh
is hour
mm
is minute
ss
is second
YYYY
is year
Example
#include <time.h> /* for asctime, tm */
#include <stdio.h> /* for printf */
volatile int i;
int main(void)
{
struct tm when;
time_t whattime;
when.tm_sec = 30;
when.tm_min = 30;
when.tm_hour = 2;
when.tm_mday = 1;
when.tm_mon = 1;
when.tm_year = 103;
whattime = mktime(&when);
printf("Day and time is %s\n", asctime(&when));
}
Example Output
Day and time is Sat Feb 1 02:30:30 2003