ctime -- Convert Local Time Value to Character String

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

asctime

SEE ALSO

Timing Functions

Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.