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\>

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

osopolar’s picture

Issue summary: View changes
osopolar’s picture

It 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).

Status: Needs review » Needs work

The last submitted patch, 2: date-d6-ignore-escaped-characters-2272285-2.patch, failed testing.

osopolar’s picture

Status: Needs work » Needs review

No problem, the D6 patch obviously failed, while it was applied to D7 version.

Chris Matthews’s picture

The 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.