1.TH CTIME 3 scc\-VERSION2.SH NAME3asctime, ctime, gmtime, localtime, mktime - convert between calendar time and broken-down time4.SH SYNOPSIS5#include <time.h>67.nf8char *asctime(const struct tm *tm);9char *ctime(const time_t *timep);10struct tm *gmtime(const time_t *timep);11struct tm *localtime(const time_t *timep);12time_t mktime(struct tm *tm);13.fi14.SH DESCRIPTION15The16.BR ctime ,17.B gmtime18and19.B localtime20functions each accept a21.B time_t22argument representing calendar time.2324The25.B asctime26and27.B mktime28functions each accept a pointer to a broken-down time structure,29which separates calendar time into components such as30year, month, and day.3132Broken-down time is stored in a33.B struct tm34object.3536Calling37.B ctime(t)38is equivalent to calling39.BR asctime(localtime(t)) .40It converts the calendar time41.I t42to a null-terminated string with the form:4344 "Wed Jun 30 21:49:08 1993\n\0"4546In the C locale, the day-of-week abbreviations are47"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", and "Sat";48the month abbreviations are "Jan", "Feb", "Mar", "Apr",49"May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", and "Dec".5051The52.B gmtime53function converts the calendar time54.I timep55to a broken-down time expressed as56Coordinated Universal Time (UTC).57It may return NULL when the conversion is not possible.5859The60.B localtime61function converts the calendar time62.I timep63to a broken-down time expressed in the user's local timezone.6465The66.B asctime67function converts the broken-down time68.I tm69to a null-terminated string using the same format as70.BR ctime .7172The73.B mktime74function converts a broken-down local time to a calendar time value.75The76.B tm_wday77and78.B tm_yday79fields of the input structure are ignored.80The remaining fields are not required to lie within their normal ranges.81Upon success, the structure is updated so that all fields reflect82the calendar time within their standard ranges,83with84.B tm_wday85and86.B tm_yday87computed accordingly.88The final value of89.B tm_mday90is resolved only after91.B tm_mon92and93.B tm_year94have been determined.9596.SH RETURN VALUE97On success,98.B gmtime99and100.B localtime101return a pointer to a102.B struct tm .103104On success,105.B asctime106and107.B ctime108return a pointer to the formatted string.109110On success,111.B mktime112returns the calendar time as a113.B time_t114value.115116On failure,117.B mktime118returns119.BR (time_t)-1 .120All other functions return NULL on failure.121On error,122.B errno123is set to indicate the cause.124.SH STANDARDS125.nf126ISO/IEC 9899:1999 7.23.2.3 Paragraph 1,2,3127ISO/IEC 9899:1999 7.23.3.1 Paragraph 1,2,3128ISO/IEC 9899:1999 7.23.3.2 Paragraph 1,2,3129ISO/IEC 9899:1999 7.23.3.3 Paragraph 1,2,3130ISO/IEC 9899:1999 7.23.3.4 Paragraph 1,2,3131.fi132.SH SEE ALSO133.BR time.h (3)