C++ date and timeLast Updated : 17 Mar 2025 In this article, we will learn about the date and time formats in C++. There is no complete format in C++ for date and time so we inherit it from the c language. To use date and time in c++, <ctime> header file is added in the program. <ctime>This header file has four time-related types as follows -
Date and time functions in c++
Example to print current date and timeBelow is the example to print the current date and time in the UTC format. Code Output The local date and time is: Wed Sep 22 16:31:40 2021 The UTC date and time is: Wed Sep 22 16:31:40 2021 The below code tells how to break the tm structure and to print each attribute independently with the use of -> operator. Code Output Number of seconds since January 1,2021 is:: 1632328553 Year:2021 Month: 9 Day: 22 Time: 21:65:53 Next TopicCopy elision in C++ |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India