C++ inherits data types for time from C language. To use these data types in your program you have to include ctime header:

#include <ctime>

This header provides 4 data types used for time representation:

clock_t - Clock type

size_t - Unsigned integral type

time_t - Time type

structtm - Time structure

The first 3 data types represent time as integers and you will need to convert these integers to get commonly used representation of time.
The most user friendly way of time representation has struct tm. What is a structure is discussed in the C++ Data Structures . The tm has the following fields that represent time:

Field

Type

Meaning

Range

tm_sec

int

seconds

0-61

tm_min

int

minutes

0-59

tm_hour

int

hours

0-23

tm_mday

int

day of the month

1-31

tm_mon

int

months since January

0-11

tm_year

int

years since 1900

tm_wday

int

days since Sunday

0-6

tm_yday

int

days since January 1

0-365

To use a variable of type tm you can declare it in the same way you declare any variable:

tm my_time;

The ctime header provides a range of useful functions to work with data types: