std::chrono::system_clock::now
来自 cppreference.com
< cpp | chrono | system clock
static std::chrono::time_point<std::chrono::system_clock> now() noexcept; |
(自 C++11 起) | |
返回表示当前时间的 time_point。
[编辑] 参数
(无)
[编辑] 返回值
表示当前时间的 time_point。
[编辑] 示例
运行此代码
#include <chrono> #include <iostream> int main() { const auto now = std::chrono::system_clock::now(); const std::time_t t_c = std::chrono::system_clock::to_time_t(now); std::cout << "The system clock is currently at " << std::ctime(&t_c); }
可能的输出
The system clock is currently at Thu Mar 30 13:28:27 2023