Python Forum

Full Version: Help regarding date format
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi,

i have date like this 31-12-2024 (dd-mm-yyyy) and i want to convert this date to Dec, 2024. How can i do that.


date = 31-12-2024


l_dt = datetime.datetime.strptime(date, '%d-%M-%Y')
l_dt = l_dt.strftime('%b; %Y')
and it prints Jan, 2024 but it should print Dec, 2024

any help?
Month input string should be a little m, big M is minute.
l_dt = datetime.datetime.strptime(date, '%d-%m-%Y')
Thank you so much