Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get default date format in wordpress

For a wordpress plugin I need the default date format set in options->general. I need the format string (like 'Y-m-d H:i:s') for usage in the Carbon library. In the documentation I didn't find anything related to this.

like image 922
Michael Wagner Avatar asked Dec 20 '22 07:12

Michael Wagner


1 Answers

Date and time formats are stored separately as options.

Use get_option() to retrieve the value.

E.g.

$date_format = get_option( 'date_format' ); // e.g. "F j, Y"
$time_format = get_option( 'time_format' ); // e.g. "H:i:s"
like image 105
Nathan Dawson Avatar answered Dec 24 '22 02:12

Nathan Dawson