Namespaces
Variants
Views
Actions

ctime

From cppreference.com
< c‎ | chrono
Revision as of 06:03, 13 April 2012 by Eendy (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:c/chrono/c/sidebar

Defined in header <time.h>
char* ctime( const time_t* time );

Converts given time since epoch to a calendar local time and then to a textual representation, as if by calling Template:cpp. The resulting string has the following format:

Www Mmm dd hh:mm:ss yyyy
  • Www - the day of the week (one of Mon, Tue, Wed, Thu, Fri, Sat, Sun).
  • Mmm - the month (one of Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec).
  • dd - the day of the month
  • hh - hours
  • mm - minutes
  • ss - seconds
  • yyyy - years

The function does not support localization.

Contents

Parameters

time - pointer to a Template:cpp object specifying the time to print

Return value

pointer to a static null-terminated character string holding the textual representation of date and time. The string may be shared between asctime and Template:cpp, and may be overwritten on each invocation of any of those functions.

Notes

This function returns a pointer to static data and is not thread-safe. In addition, it modifies the static Template:cpp object which may be shared with Template:cpp and Template:cpp. POSIX marks this function obsolete and recommends Template:cpp instead.

The behavior may be undefined for the values of time_t that result in the string longer than 25 characters (e.g. year 10000)

Example

Template:example cpp

See also

Template:c/chrono/c/dcl list asctimeTemplate:c/chrono/c/dcl list strftime