Print current date and time in C

Write a C program to print 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.

C implementation –

Download   Run Code


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.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)


Thanks for reading.

Please use our online compiler to post code in comments. To contribute, get in touch with us.
Like us? Please spread the word and help us grow. Happy coding 🙂

Leave a Reply

Notify of