Display Date and Time on the screen using Python

Noor Fakhry
2 min readApr 2, 2022

--

In this tutorial I will show you how to create a Python program that displays current date and time on the screen.

The first thing that we want to do is to import the datetime module

The datetime module provides us with classes which allow us to manipulate date and time.

After that we can declare a variable called now and initialize it like that

Now all we need to do is to print the current date and time on the screen like that

Now if we run the code

we can see that it displayed the current date and time (at the time of writing this article) on the screen

as you can see, the default format for the date is “year-month-day” and for the time is “hour-minute-second”

we can change that if we want

here is how we can do it, we can write this code for example

here we formatted the date as “day-year-month” and the time as “second-minute-hour”

Now if we run the code this will be the result

Subscribe to my YouTube channel for more programming tutorials

If you are interested in learning programming in Arabic subscribe to my other YouTube channel (the Arabic channel).

--

--

Noor Fakhry
Noor Fakhry

Written by Noor Fakhry

0 Followers

Creator @Youtube | Instructor @Udemy | Software Engineer | Masters in CS | Youtube Channel => https://bit.ly/3d7ZP5j