It seems that the character from PHP date () could not be avoided;

I'm trying to make the date equal with something like: Posted at 18:55 on 8/5/13. However, it seems I'm not sure that the "on" part is working correctly. I tried reverse reversing the characters that I want, but something similar happens every time: 06:55 PM o 8/5/13 It seems I can not show "n".

This is what I have:

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

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

+6
source share
2 answers

PHP interprets \n as a newline. To avoid this, just add an extra slash:

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

Outputs:

 04:06 AM on 08/06/13 

Live demo: http://codepad.org/oI6rIyTq

+10
source

You can also use a single quota to avoid escaping:

 echo date('h:i A \o\nm/d/y'); 
+4
source

Source: https://habr.com/ru/post/951076/


All Articles