WP_Date_Query::build_mysql_datetime

SummerySummery

Builds a MySQL format date/time based on some query parameters.

Syntax

WP_Date_Query::build_mysql_datetime( string|array $datetime, bool $default_to_max = false )

DescriptionDescription

You can pass an array of values (year, month, etc.) with missing parameter values being defaulted to either the maximum or minimum values (controlled by the $default_to parameter). Alternatively you can pass a string that will be passed to date_create().

ParametersParameters

$datetime

(string|array) (Required) An array of parameters or a strotime() string

$default_to_max

(bool) (Optional) Whether to round up incomplete dates. Supported by values of $datetime that are arrays, or string values that are a subset of MySQL date format ('Y', 'Y-m', 'Y-m-d', 'Y-m-d H:i'). Default: false.

Default value: false

ReturnReturn

(string|false) A MySQL format date/time or false on failure

SourceSource

File: wp-includes/class-wp-date-query.php


			

ChangelogChangelog

Changelog
Version Description
3.7.0 Introduced.
Scroll to Top