# C ctime / asctime Format

Key: `datetime.timestamp.ctime`

Output of C ctime() and asctime() functions, Python datetime.ctime(), Ruby Time\#to\_s. Day-of-week abbreviation, month abbreviation, space-padded day, 24-hour time, then 4-digit year.

Page: <https://meridian.online/docs/projects/finetype/types/datetime/timestamp/ctime>

Format: `%a %b %-d %H:%M:%S %Y`

Samples: `Mon Jan 15 14:30:00 2024`, `Tue Dec 31 23:59:59 2019`, `Sat Jun  1 08:15:30 2024`

## Written by

- Python `datetime.ctime()`

## Background

### Origin

The FreeBSD manual records that the asctime() function first appeared in Version 5 AT\&T UNIX.[[1]](https://man.freebsd.org/cgi/man.cgi?query=ctime&sektion=3) The asctime() and ctime() functions were standardised in C89 and POSIX.1-1988.[[2]](https://man7.org/linux/man-pages/man3/ctime.3.html) The Linux manual page states that the call ctime(t) is equivalent to asctime(localtime(t)).[[2]](https://man7.org/linux/man-pages/man3/ctime.3.html)

POSIX defines the output of asctime() with the example string Sun Sep 16 01:03:52 1973, followed by a newline and a terminating null character.[[3]](https://pubs.opengroup.org/onlinepubs/9799919799/functions/asctime.html)

asctime() and ctime() were marked obsolescent in C23 and in POSIX.1-2008, which recommend strftime(3) instead.[[2]](https://man7.org/linux/man-pages/man3/ctime.3.html) POSIX says the asctime() function is included only for compatibility with older implementations.[[3]](https://pubs.opengroup.org/onlinepubs/9799919799/functions/asctime.html) cppreference notes that the behaviour of asctime() is undefined if the year has more than 4 digits or is less than the year 1000.[[4]](https://en.cppreference.com/w/c/chrono/asctime)

### Use

Python's documentation says that, unlike the C function of the same name, time.asctime() does not add a trailing newline.[[5]](https://docs.python.org/3/library/time.html) Python's documentation says the output of datetime.ctime() will not include time zone information, whether the input is aware or naive.[[6]](https://docs.python.org/3/library/datetime.html)

RFC 9110 requires a recipient that parses a timestamp in an HTTP field to accept all three HTTP-date formats.[[7]](https://www.rfc-editor.org/rfc/rfc9110.html) RFC 9110 says values in the asctime format are assumed to be in UTC.[[7]](https://www.rfc-editor.org/rfc/rfc9110.html)

## Sources

1. [ctime(3) - FreeBSD 15.1-RELEASE and Ports.quarterly Manual Pages](https://man.freebsd.org/cgi/man.cgi?query=ctime&sektion=3) — documentation
2. [ctime(3) - Linux manual page](https://man7.org/linux/man-pages/man3/ctime.3.html) — documentation
3. [asctime](https://pubs.opengroup.org/onlinepubs/9799919799/functions/asctime.html) — standard
4. [asctime, asctime\_s - cppreference.com](https://en.cppreference.com/w/c/chrono/asctime) — secondary source
5. [time — Time access and conversions — Python 3.15.0 documentation](https://docs.python.org/3/library/time.html) — documentation
6. [datetime — Basic date and time types — Python 3.15.0 documentation](https://docs.python.org/3/library/datetime.html) — documentation
7. [RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html) — standard
