mysql_to_rfc3339()WP 4.4.0

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.

No Hooks.

Return

String. Date formatted for ISO8601 without time zone.

Usage

mysql_to_rfc3339( $date_string );
$date_string(string) (required)
Date string to parse and format.

Changelog

Since 4.4.0 Introduced.

mysql_to_rfc3339() code WP 6.5.2

function mysql_to_rfc3339( $date_string ) {
	return mysql2date( 'Y-m-d\TH:i:s', $date_string, false );
}