Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

asctime - convert date and time to string

&pagelevel(4)&pagelevel

Syntax

#include <time.h>

char *asctime(const struct tm *timeptr);

Description

asctime() converts a time specification that is broken down in accordance with the structure tm (see below) into an EBCDIC string. No check is made here to see whether the time specification is meaningful, i.e. whether, for instance, the specified number of days fits the specified month. An error exists only when the data entered cannot be displayed in the time format. Consequently the earliest possible date which can be displayed is -999, and the latest date which can be displayed is 9999.

This structure can be specified with *timeptr as defined in the header time.h:

struct tm
{
          int   tm_sec;        /* Seconds [0,61] */
          int   tm_min;        /* Minutes [0,59] */
          int   tm_hour;       /* Hours [0,23] */
          int   tm_mday;       /* Day of month [1,31] */
          int   tm_mon;        /* Months since beginning of year [0,11]*/
          int   tm_year;       /* Years since 1900 */
          int   tm_wday;       /* Weekday [0,6] Sunday=0 */
          int   tm_yday;       /* Days since January 1 [0,365] */
          int   tm_isdst;      /* Daylight saving time (ignored) */
};

asctime() is not thread-safe. Use the reentrant function asctime_r() when needed.

Return val.

Pointer to the generated EBCDIC string


if successful. The result string has a length of 26 (including the null byte) and the format of a date and time specification in English:

weekday month-name day-of-month hours:minutes:seconds year

e.g. Thu Jun 30 15:20:54 1994\n\0

EOVEFLOW

In case of an error. errno is set to indicate the error.

Notes

The asctime(), ctime(), ctime64(), gmtime(), gmtime64(), localtime() and localtime64() functions write their result into the same internal C data area. This means that each of these function calls overwrites the previous result of any of the other functions.

A structure of type tm is returned by the functions gmtime() and localtime().

The functions asctime() and asctime_r() continue to be offered for reasons of compatibility. They support neither localized date formats nor localized time formats, i.e. regional peculiarities in the representation of the date or time. To be portable, applications should use the strftime() function instead.

See also

asctime_r(), clock(), ctime(), difftime(), gmtime(), localtime(), mktime(), strftime(), time(), utime(), time.h.