Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The PHP date-documentation says:
You can prevent a recognized character in the format string from being expanded by escaping it with a preceding backslash.
date_format_order() does not ignore these escaped characters which may results in an incorrect result.
FYI: My format example (which is actually just "j M"):
\<\s\p\a\n\ \c\l\a\s\s\=\"\d\a\y\"\>j\<\/\s\p\a\n\> \<\s\p\a\n\ \c\l\a\s\s\=\"\m\o\n\t\h\"\>M\<\/\s\p\a\n\>
Comment | File | Size | Author |
---|---|---|---|
#2 | date-d6-ignore-escaped-characters-2272285-2.patch | 1.25 KB | osopolar |
#2 | date-d7-ignore-escaped-characters-2272285-2.patch | 458 bytes | osopolar |
Comments
Comment #1
osopolarComment #2
osopolarIt should be enough to just strip out the escaped characters.
Patches for D7 and D6 attached. The D6 backport patch has some more tiny changes, because I copied the complete function from D7 to D6 (this fixes documentation and coding style).
Comment #4
osopolarNo problem, the D6 patch obviously failed, while it was applied to D7 version.
Comment #6
Chris Matthews CreditAttribution: Chris Matthews commentedThe 5 year old patch for D7 in #2 still applies cleanly to the latest 7.x-2.x-dev and seems like a reasonable/necessary fix to me.