Python Get Current Month Example Tutorial

Published On: 29/08/2022 | Category: Python


Hi Guys,

Today our leading topic is python get current month example. you will learn how to get current month in python. I would like to share with you how to get current month in python 3. let’s discuss about python get today month. follow bellow step for python get current month as decimal number.

In this post, i will give you two examples to getting current month in python. we will utilize datetime module to get current month from date. so let's optically discern following examples with output:

So let's see bellow example:

Example 1: main.py
from datetime import datetime
  
today = datetime.now()
  
print("Current Date and Time :", today)
print("Current Month :", today.month)
Output:
Current Date and Time : 2022-08-29 05:52:57.926228
Current Month : 8
Example 2: main.py
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: Aug
Current Month Abbreviated Name: Aug
Current Month with Decimal Number : 08

It will help you....