• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <chrono>

    std::chrono::system_clock::now

    static time_point now() noexcept;
    

    概要

    現在日時を取得する

    戻り値

    現在日時を指すtime_point

    例外

    投げない

    #include <iostream>
    #include <chrono>
    #include <ctime>
    
    using namespace std::chrono;
    
    int main()
    {
      system_clock::time_point p = system_clock::now();
    
      std::time_t t = system_clock::to_time_t(p);
      std::cout << std::ctime(&t) << std::endl;
    }
    

    出力例

    Fri Dec 20 16:32:56 2019
    

    バージョン

    言語

    • C++11

    処理系