Python datetime How to change month number to month name

0 votes

Hi. I am using python to get the current time and date using the datetime module. The date is being printed in number.

time=datetime.datetime.now()
print(time)
2019-05-09 13:02:27.989905

I want to convert it into the name of the months. How can I do?

May 9, 2019 in Python by Raj
13,466 views

1 answer to this question.

0 votes

You can use the datetime module to convert the month to month name.

Here’s the code to do it:

time=datetime.datetime.now()
print(time.strftime("%B"))


Hope this helps!!

If you need to learn more about Python, It's recommended to join Python Training today.

Thanks!

answered May 9, 2019 by Suman

Related Questions In Python

0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2, 2019 in Python by anonymous
5,859 views
0 votes
1 answer

How to convert datetime.date to UTC timestamp in Python

In Python 3 (< 3.3) From the docs ...READ MORE

answered Oct 31, 2018 in Python by Priyaj
• 58,020 points
9,936 views
0 votes
1 answer

How to parse date/time string with timezone abbreviated name in Python?

The parse() function in dateutil can't handle ...READ MORE

answered Nov 27, 2018 in Python by Nymeria
• 3,560 points
2,260 views
0 votes
1 answer

How to change one character in a string in Python?

Python strings are immutable, you change them ...READ MORE

answered Dec 4, 2018 in Python by Nymeria
• 3,560 points
1,277 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,071 views
0 votes
1 answer

How to round a floating point number up to certain decimal place in Python?

This is normal (and has nothing to do ...READ MORE

answered Oct 8, 2018 in Python by charlie_brown
• 7,720 points
2,361 views
–1 vote
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP