Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't seem to escape character from PHP date();

Tags:

People also ask

What is the meaning of escaping to PHP?

Escaping is a technique that preserves data as it enters another context. PHP is frequently used as a bridge between disparate data sources, and when you send data to a remote source, it's your responsibility to prepare it properly so that it's not misinterpreted.

What is PHP date function?

Definition and Usage. The date() function formats a local date and time, and returns the formatted date string.

Do I need to escape in PHP?

In practice they don't have to be escaped, except for one case: if the backslash is the last character. 'foo\\' works, but 'foo\' doesn't. I think the non-escaped backslashes should be considered as a syntactic sugar. For consistency you may want to always escape them, but it's up to you.


I'm trying to make date equal something like: Posted at 06:55 PM on 8/5/13. However I can't seem to get the "on" part work correctly. I've tried backslashing the characters I want, but everytime something like this happens: 06:55 PM o 8/5/13 I can't seem to get the "n" to show up.

This is what I have:

date("h:i A \o\n m/d/y"); 

According to the php manual website this should work. Help me out? Thanks.