Ye Lin Aung
Ye Lin Aung

Reputation: 11459

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.

Upvotes: 3

Views: 207

Answers (2)

anubhava
anubhava

Reputation: 785126

Just put a backslash \ before o like this:

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

Upvotes: 4

user142162
user142162

Reputation:

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.

Upvotes: 5

Related Questions