In the PH开发者_运维技巧P 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
You'll need to insert:
&\nb\sp;
for each space that you want. That will prevent any of the characters from being recognized as special date characters.
Just a little comment: it works only in single quotes declaration, not in double ones. I mean
date('j.&\nb\sp;n.', $date)
works as described, date("j.&\nb\sp;n.", $date)
outputs mess.
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';
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.
You have to insert: "l \&\\n\b\s\p\; F d Y"
$date=date("l \&\\n\b\s\p\; F d Y","2018/08/17");
It is return with Friday August 17 2018
.
The difference is :
added double slash before "n"
.
It works fine for me. Please try
Put \t
for each space between date and time value in date
function of php ......
e.g............
date("d-m-Y \t h:i:s")
精彩评论