Let us learn to print the current date and time using Python.
We will be using the datetime module for this purpose.
First we import date from datetime module. According to the python documentation, the datetime module supplies classes for manipulating dates and times in both simple and complex ways. We assign today’s date to the variable called now and print it. We get to see the date as a tuple. Next we use strftime to convert it to a string and print it in a sentence.
%b gives the abbreviated month name.
%Y gives the year including the century.
%A gives the name of the week day.
%d gives the day of the month(1 to 31).
%B gives the name of the month.
Similarly in the above way we get the time also and print it using strftime.