.TH asctime() "" "" "Time Function (libc)"
.PC "Convert time structure to ASCII string"
.B "#include <time.h>"
\fB#include <sys/types.h>\fR
\fBchar *asctime(\fItmp\^\fB)\fR
\fBstruct tm *\fItmp\^\fB;\fR
.PP
.B asctime()
takes the data found in
.IR tmp ,
and turns it into an ASCII string.
.I tmp
is of the type
.BR tm ,
which is a structure defined in the header file
.BR time.h .
This structure must first be initialized by either
.B gmtime()
or
.B localtime()
before it can be used by
.BR asctime() .
For a further discussion of
.BR tm ,
see the entry for
.BR time .
.PP
.B asctime()
returns a pointer to where it writes the text string it creates.
.SH Example
The following
example demonstrates
the functions
.BR asctime() ,
.BR ctime() ,
.BR gmtime() ,
.BR localtime() ,
and
.BR time() ,
and shows the effect of the environmental variable
.BR TIMEZONE .
For a discussion of the variable
.BR time_t ,
see the entry for
.BR time() .
.DM
#include <time.h>
#include <sys/types.h>
main()
{
	time_t timenumber;
	struct tm *timestruct;
.DE
.DM
	/* read system time, print using ctime */
	time(&timenumber);
	printf("%s", ctime(&timenumber));
.DE
.DM	
	/* use gmtime to fill tm, print with asctime */
	timestruct = gmtime(&timenumber);
	printf("%s", asctime(timestruct));
.DE
.DM
	/* use localtime to fill tm, print with asctime */
	timestruct = localtime(&timenumber);
	printf("%s", asctime(timestruct));
}
.DE
.SH "See Also"
.Xr libc, libc
.Xr time(), time.s
.Xr "time [overview]" time.a
.br
\*(AS, \(sc7.12.3.1
.br
\*(PX, \(sc8.1.1
.SH Notes
.B asctime()
returns a pointer to a statically allocated data area
that is overwritten by successive calls.
