char* ctime (const time_t * timer);
Convert time_t value to string
Interprets the value pointed by timer as a calendar time and converts it to a C-string containing a human-readable version of the corresponding time and date, in terms of local time.
The returned string has the following format:
Where Www is the weekday, Mmm the month (in letters), dd the day of the month, hh:mm:ss the time, and yyyy the year.
The string is followed by a new-line character (
'\n') and terminated with a null-character.
This function is equivalent to:
For an alternative with custom date formatting, see strftime.
- Pointer to an object of type time_t that contains a time value.
time_t is an alias of a fundamental arithmetic type capable of representing times as returned by function time.
A C-string containing the date and time information in a human-readable format.
The returned value points to an internal array whose validity or value may be altered by any subsequent call to asctime or ctime.
/* ctime example */
#include <stdio.h> /* printf */
#include <time.h> /* time_t, time, ctime */
int main ()
printf ("The current local time is: %s", ctime (&rawtime));
The current local time is: Web Feb 13 16:06:10 2013
The function accesses the object pointed by timer.
The function also accesses and modifies a shared internal buffer, which may cause data races on concurrent calls to asctime or ctime. Some libraries provide an alternative function that avoids this data race: ctime_r (non-portable).
No-throw guarantee: this function never throws exceptions.
- Convert tm structure to string (function
- Convert time_t to tm as UTC time (function
- Convert time_t to tm as local time (function
- Get current time (function