![]() Chapter Contents |
![]() Previous |
![]() Next |
| ctime |
| Portability: | ISO/ANSI C conforming, UNIX compatible, POSIX.1 conforming |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| CAUTION | |
| IMPLEMENTATION | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <time.h> char *ctime(const time_t *timep);
| DESCRIPTION |
ctime
converts a
time_t
value (as returned by
the
time
function) 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 on the left with blanks to two characters if necessary; the hours,
minutes, and seconds are padded with 0s.)
ctime
is affected
by time zone information contained in the TZ environment variable.
| RETURN VALUE |
ctime
returns a pointer to the formatted local date and time.
| CAUTION |
The pointer returned by
ctime
may reference
static
storage,
which may be overwritten by the next call to
asctime
or
ctime
.
| IMPLEMENTATION |
ctime(timep)
is implemented as
asctime(localtime(timep))
.
| EXAMPLE |
#include <time.h>
#include <stdio.h>
main ()
{
time_t timeval;
time(&timeval);
printf("The current time and date are: %s",
ctime(&timeval));
}
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.