You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing valid directive %D in datetime.strftime() documentation #88950
It's dependent on the platform's C library's strftime(). I think (but don't promise) that we document the C89 codes, but each platform might provide additional ones.
Raphael commented on Oct 24, 2021
Raphaelmannequin
Mannequin
More actions
Perhaps it could be mentioned more clearly in the datetime documentation that apart from the directives of the C89 standard, you can also use those that the underlying libc strftime() supports.
The following sentence from https://docs.python.org/3/library/time.html#time.strftime describes it well in my opinion:
"Additional directives may be supported on certain platforms, but only the ones listed here have a meaning standardized by ANSI C."
Perhaps a reference to "man strftime" would also be helpful.
A reference to “man strftime” was added in b7117af, and moved to the current place (below the table) in #13410 -- before this PR was filed.
The sentence just above the table also says that only standard format codes are in the table.
Activity
vpjtqwv0101 commentedon Jul 30, 2021
Output of: datetime.datetime.now().strftime('%D')
is equivalent for: datetime.datetime.now().strftime('%m/%d/%y')
Is there a reason that directive %D is missing in documentation? Are there other hidden directives?
https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior
ericvsmith commentedon Jul 30, 2021
It's dependent on the platform's C library's strftime(). I think (but don't promise) that we document the C89 codes, but each platform might provide additional ones.
Raphael commentedon Oct 24, 2021
Perhaps it could be mentioned more clearly in the datetime documentation that apart from the directives of the C89 standard, you can also use those that the underlying libc strftime() supports.
The following sentence from https://docs.python.org/3/library/time.html#time.strftime describes it well in my opinion:
"Additional directives may be supported on certain platforms, but only the ones listed here have a meaning standardized by ANSI C."
Perhaps a reference to "man strftime" would also be helpful.
encukou commentedon Mar 14, 2025
A reference to “man strftime” was added in b7117af, and moved to the current place (below the table) in #13410 -- before this PR was filed.
The sentence just above the table also says that only standard format codes are in the table.
I don't think there's anything more to do here.