On Mon, August 13, 2007 12:50 pm, Kevin Murphy wrote:
Small issue with formatting a date. If I type in this:
echo date(g:i:s a \o\n l F j, Y);
the n character in the word on doesn't appear, but instead what I
get is a new line in the source code. If I type it as:
echo date(g:i:s a \on l F j, Y);
I get the number 8 (current month) where the n is supposed to be.
Is there any way to get an n in there?
As noted, apostrophes will work in this case.
If you need to embed a variable, however, you may want to re-read this
from the manual a couple times:
You can prevent a recognized character in the format string from
being expanded by escaping it with a preceding backslash. If the
character with a backslash is already a special sequence, you may need
to also escape the backslash.
So, for example:
date(g:i:s a \o\\n l F j, Y);
Here's what happens:
PHP's string parser eats the \\ and turns it into a single
back-slash: \
*THEN* you have \n being passed to the C date() function, which then
eats the \n and says:
This is then not the n for Numeric representation of a month,
without leading zeros but just a regular old n as text.
--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php