std::chrono::current_zone
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Date and time library
(C++11)
(C++20)
(C++20)
(C++11)
(C++11)
(C++11)
(C++20)
(C++20)
(C++20)
(C++11)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
current_zone
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Defined in header
<chrono>
const std::chrono::time_zone * current_zone();
(since C++20)
Convenience function for obtaining local time zone from the time zone database. Equivalent to std::chrono::get_tzdb ().current_zone().
Contents
[edit] Exceptions
std::runtime_error if this is the first reference to the time zone database and the time zone database cannot be initialized.
[edit] Notes
A call to this function that is the first reference to the time zone database will cause it to be initialized.
[edit] Example
Run this code
#include <chrono> #include <iostream> int main() { try { const std::chrono::zoned_time cur_time { std::chrono::current_zone(), // may throw std::chrono::system_clock::now () }; std::cout << cur_time << '\n'; } catch(const std::runtime_error & ex) { std::cerr << ex.what() << '\n'; } }
Possible output:
2021年09月13日 19:46:42.249182012 MAGT