php – Convert custom field date format to “WordPress default”

Question

Hello ladies and gents,

I’m using F j, Y (e.g. December 28, 2022) as default date format on my site (set in the admin settings). I have an event custom post type with an event_start_date custom field.

By default, event_start_date outputs a date in format Y-m-d (i.e. 2022-12-28), but I want it displayed in the same format as my default settings, i.e. F j, Y.

I can change this default format, and know I can add some code to my function.php to convert it to another format. But what I would really like to do is convert is to whatever date format is set in the WordPress admin settings.

That way my customer can change the date via WordPress admin settings and it will change the format everywhere, without having to touch the code.

I haven’t found anything on how to achieve that; is it possible? Thank you for your help.

PS: Furthermore, I need the date to be converted wherever it might show up: on a ‘static’ page, in a query loop, etc.

0
nomade0 1 month 2022-12-28T18:32:40-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse