Hello,
In the PHP date function below, I would like to put a few spaces between "a" and "\N\e\w". How is it done?
'l, F j, Y, g:i a \N\e\w \Y\o\r\k \t\i\m\e'
Thanks in advance,
John
Hello,
In the PHP date function below, I would like to put a few spaces between "a" and "\N\e\w". How is it done?
'l, F j, Y, g:i a \N\e\w \Y\o\r\k \t\i\m\e'
Thanks in advance,
John
As far as I'm aware, the date() function does not ignore any whitespace you put into the format string. So put as much space as you need in there.
You will probably, however, need to use for consecutive spaces in your HTML output, if you do not want browsers to ignore the extra whitespace.
Rather than put directly into your date format string (you would need to escape it of course), it would be better to do any necessary conversion of consecutive spaces to non-breaking spaces separately. Then you can have a single function that does that, and forget about putting in all your format strings. This will come in especially useful if you ever have to generate output that isn't HTML.
For clarity's sake, you may just want to rewrite this like:
date('l, F j, Y, g:i a').' New York time';
My advice would be to not place the string literal inside the date formatting string, so you don't have to escape it:
$string = date('l, F j, Y, g:i a'). ' (or ) New York Time';