Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting date to a String

I've faced with converting Date to String by using date() function in php.

Simply, I just want to print this '17th of January 2012' by using format character.

print date("jS of F Y");

However, the output was 17th 2012f January 2012 and.. is there any way to escape 'o' string to get the output I want.

like image 756
Ye Lin Aung Avatar asked Feb 24 '26 14:02

Ye Lin Aung


1 Answers

Escape the o with a backslash:

print date("jS \of F Y");

From the documentation:

You can prevent a recognized character in the format string from being expanded by escaping it with a preceding backslash.