### ctime -- Convert Time to Character String

Format

>     #include <time.h>
>     char *ctime(const time_t *time);

Language Level: ANSI, POSIX, XPG4
ctime converts the time value pointed to by time to local time in the form of a character string. A time value is usually obtained by a call to the time function.

The string result produced by ctime contains exactly 26 characters and has the format:

       "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n"

For example:

       Mon Jul 16 02:03:55 1987\n\0

ctime uses a 24-hour clock format. The days are abbreviated to: Sun, Mon, Tue, Wed, Thu, Fri, and Sat. The months are abbreviated to: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec. All fields have a constant width. Dates with only one digit are preceded with a blank space. The new-line character (\n) and the null character (\0) occupy the last two positions of the string.

Note:
On both OS/2 and Windows, the time and date functions begin at 00:00:00 Universal Time, January 1, 1970, and do not have an upper limit.

Return Value
ctime returns a pointer to the character string result. There is no error return value. A call to ctime is equivalent to:

> `asctime(localtime(&anytime))`

Note: The asctime, ctime, and other time functions may use a common, statically allocated buffer for holding the return string. Each call to one of these functions may destroy the result of the previous call.

Example
This example polls the system clock using ctime. It then prints a message giving the current date and time.

    #include <time.h>
    #include <stdio.h>

    int main(void)
    {
       time_t ltime;

       time(&ltime);
       printf("the time is %s", ctime(&ltime));
       return 0;

       /******************************************
          The output should be similar to:

          The time is Thu Dec 15 18:10:23 1994
       ******************************************/
    }

asctime -- Convert Time to Character String
gmtime -- Convert Time
localtime -- Convert Time
mktime -- Convert Local Time
setlocale -- Set Locale
strftime -- Convert to Formatted Time
time -- Determine Current Time
<time.h>