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

Time:12-12

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)

CodePudding user response:

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()
  • Related