Coder Latvia Coder Latvia - 1 month ago 20
PHP Question

Wordpress date format

Is it possible to use some constant strings in date formatting in Wordpress?



something like:

year:Y, month:F


which would translate to:

year:2012, month:February

Answer

Yes that's possible. Wordpress uses the php: date-function to format the date, thus you can use the following format on the general settings page of your blog.

To use constant string you will need to escape every character that should not be parsed as part of the date:

\y\e\a\r: Y, \m\o\n\t\h: F

This formatting string will result in "year: 2013, month: February".

See also the Wordpress Codex on formatting date and time.