C Reference function asctime()
Usage of asctime():
char * asctime ( const struct tm * ptr_time );
Parameters:
ptr_time is a pointer to a tm structure which in turn contains a calendar time.
Return Value:
The function returns a C string containing the date and time information.
The string is followed by a new-line character (‘\n’) and the terminating null-character.
The functions ctime and asctime share the array which holds this string. If either one of these functions is called, the content of the array is overwritten.
Explanation:
The function asctime() interprets the contents of the tm structure as calendar time and converts it to a string. The returned string contains a human-readable version of the date and time. The string that is returned will have the following format:
Www Mmm dd hh:mm:ss yyyy
Www = which day of the week.
Mmm = month in letters.
dd = the day of the month.
hh:mm:ss = the time in hour, minutes, seconds.
yyyy = the year.
Source code example of asctime():
#include <stdio.h>
#include <time.h>
int main ()
{
time_t time_raw_format;
struct tm * ptr_time;
time ( &time_raw_format);
ptr_time = localtime ( &time_raw_format );
printf ( "The current date and time is: %s", asctime(ptr_time));
return 0;
}
Output example of the program above:
The current date and time is: Fri Jan 11 11:59:51 2008
THANK YOU SO MUCH THESE INFO WILL BE VERY USE FULL DO MY PROJECT…