Documentation Home >> Headers >> <chrono> Header >> std::chrono::system_clock class

The std::chrono::system_clock class provides a means of obtaining the current wall-clock time from the system-wide real-time clock. The current time can be obtained by calling std::chrono::system_clock::now(). Instances of std::chrono::system_clock::time_point can be converted to and from time_t with the std::chrono::system_clock::to_time_t() and std::chrono::system_clock::from_time_t() functions. They system clock is not steady, so a subsequent call to std::chrono::system_clock::now() may return an earlier time than a previous call (e.g. if the operating system clock is manually adjusted, or synchronized with an external clock). std::chrono::system_clock::to_time_point() is the old name for std::chrono::system_clock::from_time_t(), and is provided for backwards compatibility only. It will be removed in some future release.

class system_clock
{
public:
    typedef unspecified-integral-type rep;
    typedef std::ratio<
        unspecified,unspecified> period;
    typedef std::chrono::duration<rep,period> duration;
    typedef std::chrono::time_point<system_clock>
        time_point;
    static const bool is_steady=false;

    static time_point now() noexcept;

    static time_t to_time_t(const time_point& t) noexcept;
    static time_point from_time_t(time_t t) noexcept;

    // for backwards compatibility only
    static time_point to_time_point(time_t t) noexcept;
    static const bool is_monotonic=false;
};
Header

#include <chrono>

See Also