ctime64() — Convert Time to Character String

Format

#include <time.h>
char *ctime64(const time64_t *time);

Language Level: ILE C Extension

Threadsafe: No. Use ctime64_r() instead.

Locale Sensitive: The behavior of this function might be affected by the LC_TOD category of the current locale. For more information, see Understanding CCSIDs and Locales.

Description

The ctime64() function 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 time64() function.

The string result that is produced by the ctime64() function 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

The ctime64() function uses a 24-hour clock format. The month and day abbreviations used are retrieved from the locale. All fields have a constant width. Dates with only 1 digit are preceded with a zero. The new-line character (\n) and the null character (\0) occupy the last two positions of the string.

Return Value

The ctime64() function returns a pointer to the character string result. If the function is unsuccessful, it returns NULL. A call to the ctime64() function is equivalent to:

   asctime(localtime64(&anytime))
Note:
The asctime() and ctime64() functions, and other time functions can use a common, statically allocated buffer to hold the return string. Each call to one of these functions might destroy the result of the previous call. The asctime_r(), ctime64_r(), gmtime64_r(), and localtime64_r() functions do not use a common, statically allocated buffer to hold the return string. These functions can be used in place of asctime(), ctime64(), gmtime64(), and localtime64(), if reentrancy is desired.

Example that uses ctime64()

This example polls the system clock using time64(). It then prints a message that gives the current date and time.

#include <time.h>
#include <stdio.h>
 
int main(void)
{
   time64_t ltime;

   time64(&ltime); 

   printf("the time is %s", ctime64(&ltime));
}

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]