in this article we will cover an python get current month. step by step explain how to get current month in python & also implement How to Get Current Month in Python 3.
Let’s Get Started :
Table of Contents
Example 1: How to Get Current Month in Python?
from datetime import datetime
today = datetime.now()
print("Current Date and Time :", today)
print("Current Month :", today.month)
Output :
Current Date and Time : 2022-06-01 7:39:19.498909
Current Month : 7
Example 2:
from datetime import datetime
today = datetime.now()
month1 = today.strftime("%b")
print("Current Month Full Name:", month1);
month2 = today.strftime("%b")
print("Current Month Abbreviated Name:", month2);
month3 = today.strftime(%m)
print("Current Month with Decimal Number :", month3);
Output :
Current Month Full Name : January
Current Month Abbreviated Name : Jan
Current Month with Decimal Number : 01
I hope you like this How to Get Current Month in Python? article.
Also Read :
- How to Check if Today is Friday or not in Python?
- GET Request with Parameters
- POST Request with Parameters Example
- Top 10 VS Code extensions
- Angular Material Grid Layout Example
- Angular Material Card Example