Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thonny datetime
#7
date.today() will return datetetime.date object. That's why you get <class 'datetime.date'> - that's exactly representation of instance of class datetime.date.
if you want to get meaningful string representation use strftime() method of datetime.date object


from datetime import date
today = date.today()
print(today.strftime('%d-%m-%Y'))
print(today.strftime('%d-%b-%Y'))
Output:
31-01-2019 31-Jan-2019
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Thonny datetime - by DeveloperM - Jan-28-2019, 09:47 PM
RE: Thonny datetime - by woooee - Jan-28-2019, 10:25 PM
RE: Thonny datetime - by buran - Jan-29-2019, 12:06 PM
RE: Thonny datetime - by DeveloperM - Jan-31-2019, 06:22 PM
RE: Thonny datetime - by buran - Jan-31-2019, 06:38 PM
RE: Thonny datetime - by DeveloperM - Jan-31-2019, 07:42 PM
RE: Thonny datetime - by buran - Jan-31-2019, 08:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Thonny Kundan 1 2,329 Aug-14-2019, 03:50 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020