Voraussetzungen
- ISO C++ 20 Standard (/std:c++20)
Code
Das Beispiel gibt UTC mit Sekundengenauigkeit aus, etwa 2026-11-23T00:00:00Z.
| |
%Fformatiert das Datum und%Tdie Uhrzeit.TundZim Formatstring sind literale Zeichen; dersystem_clock-Zeitpunkt wird als UTC formatiert. Bei einer Zeitauflösung unter einer Sekunde können Nachkommastellen erscheinen. Die Chrono-Formatierung gehört zur C++20-Bibliothek, wird aber nicht von jeder Standardbibliothek gleich unterstützt. Prüfen Sie Compiler und Bibliothek.
![Featured image of post [C++20] Aktuelle Zeit mit std::chrono und std::format als UTC im ISO-8601-Format ausgeben](/p/c-%E3%81%A7%E7%8F%BE%E5%9C%A8%E6%99%82%E5%88%BB%E3%82%92iso8601%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88%E3%81%A7%E5%87%BA%E5%8A%9B%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/img_hu14325398801108400926.webp)