Andy Groom
Andy Groom

Reputation: 629

Escaping normal text in date() doesn't work as expected

I can't work out why a date won't format how I want, I'm using:

date("F jS Y \a\t g:i a")

expecting to get:

August 11th 2015 _at_ 9:59 am

But instead I get:

August 11th 2015 _a_ 9:59 am

I can't figure out what I am doing wrong!

Upvotes: 1

Views: 40

Answers (2)

Happy Coding
Happy Coding

Reputation: 2525

Try this :

echo date("F jS Y \a\\t g:i a");

Upvotes: 0

Rizier123
Rizier123

Reputation: 59701

\t is an escape sequence and you have to escape it twice, otherwise PHP thinks it is a tab.

Like this:

date("F jS Y \a\\t g:i a")
             //^^ See here

Upvotes: 4

Related Questions