Python Datetime Strptime Error: ‘-‘ is a bad directive in format ‘%-m-%-d-%y %-H:%M:%S’

%-* — to skip padding — is a GNU libc extension. It’s not part of POSIX strftime, and thus not guaranteed to be portable to systems where your time-formatting calls aren’t eventually backed by GNU’s strftime C library function.

The Python datetime module documentation explicitly specifies the format strings it supports, and this extension is not given. Thus, while this is supported in GNU date and GNU strftime(), it isn’t available in Python datetime.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)