#include <time.h> char *asctime(const struct tm *timeinfo);
asctime
converts a broken-down time value (as stored in a
tm
structure) to a printable character string and returns the address
of the first character of the string.
The string has the form "wkd mon dd hh:mm:ss yyyy\n
", for
example "Thu Oct 10 16:49:07 1985\n
". The length of the
string is always 25. The day of the month is padded with blanks on
the left to two characters, if necessary (for example, Oct 09). The
hours, minutes, and seconds are padded with 0s.
asctime
returns a pointer to the formatted date and time.
asctime
may reference static
storage, which may be overwritten by the next call to asctime
or ctime
.
#include <stdio.h> #include <time.h> main () { time_t timeval; struct tm *now; time(&timeval); now = gmtime(&timeval); /* Get current GMT time */ printf("The current GMT time and date are: %s", asctime(now)); }
ctime
, strftime
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.