datetime '08-déc-2022 09:02' does not match format '%d-%b-%y %H:%M'

Question:

i try to get obj but i can’t please any solution thank you !

def check_date(get_date):
        date_obj = datetime.datetime.strptime('08-déc-2022 09:02','%d-%b-%y %H:%M')
        print('date object formta',date_obj)
Asked By: Soffyan.js

||

Answers:

One thing I’ve noticed is that you need to use %Y as it stands for the 4 digits notation of a year (2022), where %y is just 2 digits (22)

Another thing, the Month abbreviation has to start with an uppercase letter (Déc)

Also, it really depends on your locale, as in mine, I couldn’t use Déc and had to use Dec

You can check your locale via:

import locale
locale.getlocale()
Answered By: Meny Issakov
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.