Jump to content

What is the Current Time Around the World? -- Bartlomiej Filipek


Horizon

Recommended Posts

2024-11-21_12-48-43.pngIn this blog post, we will explore handling dates using std::chrono, including time zones. We’ll utilize the latest features of the library to retrieve the current time across various time zones, taking into account daylight saving time changes as well. Additionally, we will incorporate new capabilities introduced in C++23, such as enhanced printing functions and more.

What is the Current Time Around the World? Utilizing std::chrono with Time Zones in C++23

by Bartlomiej Filipek

From the article:

Let’s start with the following code that prints the current date and time:

#include <chrono>
#include <print>

int main() {
    auto now = std::chrono::system_clock::now();
    std::print("now is {}", now);
}

You can run it through Compiler Explorer

In my session, I’m getting the following results:

Now is 2024-11-01 11:44:06.374573703

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...