mysql_to_rfc3339

The timeline below displays how wordpress function mysql_to_rfc3339 has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.1

/**
 * Parses and formats a MySQL datetime (Y-m-d H:i:s) for ISO8601 (Y-m-d\TH:i:s).
 *
 * Explicitly strips timezones, as datetimes are not saved with any timezone
 * information. Including any information on the offset could be misleading.
 *
 * Despite historical function name, the output does not conform to RFC3339 format,
 * which must contain timezone.
 *
 * @since 4.4.0
 *
 * @param string $date_string Date string to parse and format.
 * @return string Date formatted for ISO8601 without time zone.
 */
function mysql_to_rfc3339($date_string)
{
    return mysql2date('Y-m-d\TH:i:s', $date_string, false);
}

WordPress Version: 4.4

/**
 * Parses and formats a MySQL datetime (Y-m-d H:i:s) for ISO8601/RFC3339.
 *
 * Explicitly strips timezones, as datetimes are not saved with any timezone
 * information. Including any information on the offset could be misleading.
 *
 * @since 4.4.0
 *
 * @param string $date_string Date string to parse and format.
 * @return string Date formatted for ISO8601/RFC3339.
 */
function mysql_to_rfc3339($date_string)
{
    $formatted = mysql2date('c', $date_string, false);
    // Strip timezone information
    return preg_replace('/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted);
}