convert time information to a string
#include <time.h>
char * asctime( const struct tm *timeptr );
char *_asctime( const struct tm *timeptr,
char *buf );
The asctime() functions convert the time information in the structure pointed to by timeptr into a string containing exactly 26 characters. This string has the form shown in the following example:
Sat Mar 21 15:58:27 1987\n\0
All fields have a constant width. The new-line character '\n' and the null character '\0' occupy the last two positions of the string.
The ANSI function asctime() places the resulting string in a static buffer that is re-used each time asctime() or ctime is called.
The non-ANSI function _asctime() places the resulting string in the buffer pointed to by buf.
The asctime() functions return a pointer to the character string result.
clock(), ctime(), difftime(), gmtime(), localtime(), mktime(), strftime(), time(), tzset()
The tm structure is described in the section “time.h” in the chapter C Library Overview.
#include <stdio.h>
#include <time.h>
void main()
{
struct tm time_of_day;
time_t ltime;
char buf[26];
time( <ime );
_localtime( <ime, &time_of_day );
printf( "Date and time is: %s\n",
_asctime( &time_of_day, buf ) );
}
produces the output:
Date and time is: Sat Mar 21 15:58:27 1987
All (except Netware, DOS/PM)