Write a C program to print the current date and time in standard output.

We know that time.h header file contains definitions of functions to get and manipulate date and time information. The following C source code prints the current date and time to the standard output stream using tm structure, which holds calendar date and time broken down into its components.

 
Following is a simple C implementation to get the current date and time:

Download  Run Code

Output:

Today is Sun Apr 2 23:23:59 2017
Time is 11:23:59 pm
Date is: 02/04/2017

 
In C++ 11, we can also use std::chrono::system_clock::now(), which returns a time point representing the current point in time.

That’s all about printing the current date and time in C.