Table of Contents

ctime

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

Description

The ctime() function shall convert the time pointed to by clock, representing time in seconds since the Epoch, to local time in the form of a string. It shall be equivalent to

   asctime(localtime(clock))

1970-01-01 00:00:00 +0000 (UTC).

return value

The ctime() function shall return the pointer returned by asctime() with that broken-down time as an argument.
Upon successful completion, ctime_r() shall return a pointer to the string pointed to by buf. When an error is encountered, a null pointer shall be returned.

ctime c example

/* 
 * ctime example code
 * http://code-reference.com/c/time.h/ctime 
 */
#include <stdio.h>
#include <time.h>
 
int main(void)
{
    time_t time_format;
 
    time(&time_format);
    printf("%s\n", ctime(&time_format));
 
    return 0;
}

output for this example

  
  Mon Apr 23 18:24:18 2012

see also

asctime() clock() difftime() gmtime() localtime() mktime() strftime() strptime() time() utime()