C++ Program to Print Current Day, Date, and Time in Command Line

If you want to Print Current Date, Day, and Time in Command Line using C++ Program then you are in the perfect article. Can I start the article to teach the prospects to execute this task below? Let’s go.

C++ Program to Print Current Day, Date, and Time in Command Line

C++ Program to Print Current Day, Date, and Time in Command Line

Source Code

// C++ program to find Current Day, Date
// and Local Time
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
    // Declaring argument for time()
    time_t tt;

    // Declaring variable to store return value of
    // localtime()
    struct tm * ti;

    // Applying time()
    time (&tt);

    // Using localtime()
    ti = localtime(&tt);

    cout << "Current Day, Date and Time is = "
        << asctime(ti);

return 0;
}

Conclusion

I hope this article helps you to Print Current Date, Day, and Time in Command Line Using C++ Program. Please contact us via the comment section if you have any doubts about this topic. Share this tutorial with your friends to help them.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment