Get Unix timestamp with C++

C++20 introduced a guarantee that time_since_epoch is relative to the UNIX epoch, and cppreference.com gives an example that I’ve distilled to the relevant code, and changed to units of seconds rather than hours: #include <iostream> #include <chrono> int main() { const auto p1 = std::chrono::system_clock::now(); std::cout << “seconds since epoch: ” << std::chrono::duration_cast<std::chrono::seconds>( p1.time_since_epoch()).count() << … Read more