# C Date and time utilities

> C++ Atlas: `cppatlas.com/w/cpp/chrono/c` | Source: https://en.cppreference.com/w/cpp/chrono/c | Domain: Date and time utilities | Standards: C++17

## Official Specification Summary (cppreference)

### Functions

Defined in header `<ctime>`

**Time manipulation**

- `difftime`: computes the difference between times (function)
- `time`: returns the current time of the system as time since epoch (function)
- `clock`: returns raw processor clock time since the program is started (function)
- `timespec_get` (C++17): returns the calendar time in seconds and nanoseconds based on a given time base (function)

**Format conversions**

- `asctime`: converts a `std::tm` object to a textual representation (function)
- `ctime`: converts a `std::time_t` object to a textual representation (function)
- `strftime`: converts a `std::tm` object to custom textual representation (function)
- `wcsftime`: converts a `std::tm` object to custom wide string textual representation (function)
- `gmtime`: converts time since epoch to calendar time expressed as Universal Coordinated Time (function)
- `localtime`: converts time since epoch to calendar time expressed as local time (function)
- `mktime`: converts calendar time to time since epoch (function)

### Constants

- `CLOCKS_PER_SEC`: number of processor clock ticks per second (macro constant)

### Types

- `tm`: calendar time type (class)
- `time_t`: time since epoch type (typedef)
- `clock_t`: process running time (typedef)
- `timespec` (C++17): time in seconds and nanoseconds (struct)

### See also

- [C documentation for Date and time utilities](https://en.cppreference.com/w/c/chrono)

---
Attribution: content from https://en.cppreference.com/w/cpp/chrono/c (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.