How to Get Current Day in Python?

By Hardik Savani October 30, 2023 Category : Python

This is a short guide on python get current day. I’m going to show you about how to get current day in python. Here you will learn how to get current day in python 3. we will help you to give example of python get today day. Here, Creating a basic example of python get current day as decimal number.

In this post, i will give you three examples to getting current day in python. we will use datetime module to get current day from date. so let's see following examples with output:

Example 1:

main.py

from datetime import datetime
  
today = datetime.now()
  
print("Current Date and Time :", today)
print("Current Day :", today.day)

Output:

Current Date and Time : 2022-05-02 09:33:51.346666
Current Day : 02

Example 2:

main.py

from datetime import datetime
  
today = datetime.now()
  
day1 = today.strftime("%d")
print("Current Day with zero :", day1);
  
day2 = today.strftime("%-d")
print("Current Day :", day2);

Output:

Current Day with zero : 02
Current Day : 2

I hope it can help you...

Tags :
Shares