Edit report at https://bugs.php.net/bug.php?id=45972&edit=1
ID: 45972
Comment by: dillydadally at yahoo dot com
Reported by: woeterman at gmail dot com
Summary: Date escaping goes incorrectly
Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Linux Debian
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
I whole-heartedly disagree that this is not a bug, as does the PHP.net
documentation itself! If you look at the documentation, "\t" is used all over
in the examples to represent how to type the letter t. For example, these are
copied from the documentation:
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');
The backslash in the tab character should have to be escaped, so the tab
character should be \\\t. What's worse is this is not expected behavior and
there is no solution or note posted in the php documentation, leaving many
people confused.
Previous Comments:
------------------------------------------------------------------------
[2008-09-02 11:46:23] [email protected]
That's because normal string escape rules still apply, and \t is the tab
character.
------------------------------------------------------------------------
[2008-09-02 11:37:42] woeterman at gmail dot com
Description:
------------
When escaping with date("\t"), it shows up as nothing instead of 't'.
It seems to work fine with other characters, such as \a
Reproduce code:
---------------
<?php
echo "1: ". date("jS \of F Y H:i:s"). "<br />";
echo "2: ". date("jS \of F Y at H:i:s"). "<br />";
echo "3: ". date("jS \of F Y \at H:i:s"). "<br />";
echo "4: ". date("jS \of F Y \a\t H:i:s"). "<br />";
echo "5: ". date("jS \of F Y \t H:i:s"). "<br />";
?>
Expected result:
----------------
1: 2nd of September 2008 13:36:57
2: 2nd of September 2008 pm30 13:36:57
3: 2nd of September 2008 a30 13:36:57
4: 2nd of September 2008 at 13:36:57
5: 2nd of September 2008 t 13:36:57
Actual result:
--------------
1: 2nd of September 2008 13:36:57
2: 2nd of September 2008 pm30 13:36:57
3: 2nd of September 2008 a30 13:36:57
4: 2nd of September 2008 a 13:36:57
5: 2nd of September 2008 13:36:57
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=45972&edit=1