Print system time in C++ (3 different ways) Last Updated : 10 Dec, 2018 Comments Improve Suggest changes Like Article Like Report First Method Printing current date and time using time() Second Method CPP // CPP program to print current date and time // using time and ctime. #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { // declaring argument of time() time_t my_time = time(NULL); // ctime() used to give the present time printf("%s", ctime(&my_time)); return 0; } Output: It will show the current day, date and localtime, in the format Day Month Date hh:mm:ss Year Third Method Here we have used chrono library to print current date and time . The chrono library is a flexible collection of types that tracks time with varying degrees of precision . The chrono library defines three main types as well as utility functions and common typedefs. -> clocks -> time points -> durations Code to print current date, day and time . CPP // CPP program to print current date and time // using chronos. #include <chrono> #include <ctime> #include <iostream> using namespace std; int main() { // Here system_clock is wall clock time from // the system-wide realtime clock auto timenow = chrono::system_clock::to_time_t(chrono::system_clock::now()); cout << ctime(&timenow) << endl; } Output: It will show the current day, date and localtime, in the format Day Month Date hh:mm:ss Year Comment More infoAdvertise with us Next Article C++ Program to Print Current Day, Date and Time S Surya Priy Follow Improve Article Tags : Misc C++ cpp-puzzle date-time-program Practice Tags : CPPMisc Similar Reads strftime() function in C/C++ strftime() is a function in C which is used to format date and time. It comes under the header file time.h, which also contains a structure named struct tm which is used to hold the time and date. The syntax of strftime() is as shown below : size_t strftime(char *s, size_t max, const char *format, c 3 min read mktime() function in C++ STL The mktime() is an inbuilt C++ function which converts the local calendar time to the time since epoch and returns the value as an object of type time_t. Syntax : time_t mktime( struct tm *time_ptr ) Parameters: The function accepts a mandatory parameter pointer time_ptr that points to a tm object s 2 min read Timer in C++ using system calls The task is to create timer without using any graphics or animation. The timer will be made using system calls wherever necessary. Timer in this context means a stopwatch with up-counting of time.The timer is created in Linux. Following system calls of Linux are used: sleep() : It will make the prog 2 min read Date and Time Parsing in C++ The Date and time parsing is a common task in programming especially when dealing with user input or data from external sources. C++ provides various utilities and libraries to handle date and time parsing efficiently. Some of the most commonly used libraries for date and time parsing in C++ are: 5 min read C++ Program to Print Current Day, Date and Time In order to facilitate finding the current local day, date, and time, C++ has defined several functions in the header file, so functions that will help us in achieving our objective of finding the local day, date, and time are: time(): It is used to find the current calendar time.Its return type is 2 min read Time difference between expected time and given time Given the initial clock time h1:m1 and the present clock time h2:m2, denoting hour and minutes in 24-hours clock format. The present clock time h2:m2 may or may not be correct. Also given a variable K which denotes the number of hours passed. The task is to calculate the delay in seconds i.e. time d 5 min read Like