Python Get Current Month Example

12-Aug-2022

.

Admin

Python Get Current Month Example

Hi Dev,

This post will give you example of Python Get Current Month Example. let’s discuss about Python Get Current Month. step by step explain How to Get Current Month in Python 3. let’s discuss about Python Get Today Month. You just need to some step to done How to Get Current Month in Python.

In this post, i will give you two examples to getting current month in python. we will use datetime module to get current month 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 Month :", today.month)

Output:

Current Date and Time : 2022-06-01 09:19:25.514112

Current Month : 6

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: January

Current Month Abbreviated Name: Jan

Current Month with Decimal Number : 01

#Python