std::tm

Header: <ctime>

Structure holding a calendar date and time broken down into its components.

# Declarations

struct tm;

# Notes

BSD, GNU and musl C library support two additional members, which are standardized in POSIX.1-2024.

# Example

#include <ctime>
#include <iostream>
 
int main()
{
    std::tm tm{};
    tm.tm_year = 2022 - 1900;
    tm.tm_mday = 1;
    std::mktime(&tm);
 
    std::cout << std::asctime(&tm); // note implicit trailing '\n'
}

# See also