如何防止我的时间以不同的风格展示?

Hey so here it is I got my own time code :

<?php
date_default_timezone_set('America/Los_Angeles');
echo date("F j, Y,[<\d\iv \i\d='\tx\t'></\d\iv>] a");
?>

or this one:

";       
date_default_timezone_set('America/Los_Angeles');
echo(date("F j, Y"));
echo "<div id='txt'></div>";
echo "

The time works on both of those codes, the issue is how it displays. It displays in 2 lines instead of one, here is the code:

July 14, 2013
11:15:12

Instead of being like this:

July 14, 2013 11:15:12

How can I display it in a single line?

Instead of a div use a span. divs are block level elements so its going to be on its own line. You could also style the div to have a display of inline or inline-block.

You don't seem to be displaying the time at all, but I'm going to assume you forgot to include that in your example code. The main problem is you are using a div which is what is forcing a newline after the date.

Also, note that you should be using two backslashes to escape the characters that you don't want interpreted by the date function, otherwise some will be interpreted as control characters (e.g. \t will become a tab). I would also recommend escaping all characters, not just the ones that are known formatting characters.

I suspect you want something more like this:

echo date("F j, Y, <\\s\\p\\a\
 \\i\\d='\\t\\x\\t'>h:i:s</\\s\\p\\a\
> a");

As an alternative to using double backslashes, you could also just use a single quoted string which won't try and interpret control characters.

echo date('F j, Y, <\s\p\a
 \i\d=\'\t\x\t\'>h:i:s</\s\p\a
> a');