Asctime() - C library function Program
Declaration :
1 |
char *asctime(const struct tm *timeptr) |
Explanation :
Purpose | The C library function char *asctime(const struct tm *timeptr) returns a pointer to a string which represents the day and time of the structure struct timeptr. |
Parameters | |
Return Value | This function returns a C string containing the date and time information in a human-readable format Www Mmm dd hh:mm:ss yyyy Where Www is the weekday Mmm the month in letters dd the day of the month hh:mm:ss the time and yyyy the year. |
Exception |
C Program : Example
The following example shows the usage of asctime() function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include <stdio.h> #include <string.h> #include <time.h> int main() { struct tm t; t.tm_sec = 10; t.tm_min = 10; t.tm_hour = 6; t.tm_mday = 25; t.tm_mon = 2; t.tm_year = 89; t.tm_wday = 6; puts(asctime(&t)); return(0); } |