How to Get Current Day in Python?
Hi Dev,
This tutorial will give you example of Python Get Current Day Example. you can understand a concept of Python Get Today Day. Here you will learn Python Get Current Day. We will look at example of How to Get Current Day in Python.
In this post,i will give you two examples to getting current year in python. we will use datetime module to get current year 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
- Get Last 2 Digits of Number in Python Tutorial Example
- How to Sum of First and Last Digit of Number in Python?
- How to Get First and Last Digit of Number in Python?
- Get the Last Digit of Number in Python Tutorial Example
- Get the First Digit of Number in Python Tutorial Example
- How to Remove All Decimals from Number in Python?
- How to Convert String to Float with 2 Decimal Places in Python?
- How to Format Number to 2 Decimal Places in Python?