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.

Related posts

Leave a Reply

1 comment

  1. 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"