Skip to content

Using utx::print_time


Print one time point

Use utx::print_time to print c++ time point and use utx::print to print time duration:

#include <utxcpp/core.hpp>
#include <chrono>

int main()
    // time point
    auto t1 = std::chrono::system_clock::now();

    // time duration
    auto td = std::chrono::seconds(47);


utx::print_time supports std::chrono::system_clock, other c++ clocks might cause issues.


10:13:9.49 12.23 2022

Print many time points

utx::print can print many time points with one call.

#include <utxcpp/core.hpp>
#include <chrono>

int main()
    auto t1 = std::chrono::system_clock::now();
    auto t2 = std::chrono::system_clock::time_point{};
    t2 -= std::chrono::years(20);
    auto t3 = std::chrono::time_point<std::chrono::system_clock>{};
    t3 += std::chrono::years(100);
    auto t4 = t3 + (t1-t2) + (t1-t3);

    utx::print_time(t1, t2, t3, t4);


10:34:46.463 12.23 2022
3:36:0.0 1.1 1950
6:0:0.0 12.31 2069
17:33:32.927 12.14 2095





No Trackbacks


Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.

Form options

Submitted comments will be subject to moderation before being displayed.