C program to print date

In this tutorial you will learn about the C program to print date and its application with practical example.

In this tutorial, we will learn to find current system date day and time  using C programming language. There are many  different method to find system date and time in C programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • C library.
  • Operators.
  • in-built  functions.
  • Basic input/output.
  • Basic C programming.

Often we need to work on current date and time in our program.

C program to print date

Here we write a program, in which we want to  check current date and time to  given date and time to confirm the user age .Now we will see how to write a C program to print current date and time.

Output

Here how the above program works:

Here we have taken The time_t datatype it is a data type from the C ISO library  which is define to store system’s time value.

time() function will returns the system date and time.

With the help of  function ctime()  it will returns a string that shows the local time based on t (parameter) timer. This ctime() function is defined in time.h header file.we just need to include inbuilt header file in our program and function define within header file just need call them and that’s it our will call system day and all..

that will give the current day, month , date , time and year..

In this tutorial we have learn about the C program to print date and its application with practical example. I hope you will like this tutorial.