mysql_to_rfc3339( string $date_string )
Parses and formats a MySQL datetime (Y-m-d H:i:s) for ISO8601 (Y-m-d\TH:i:s).
Description
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.
Parameters
- $date_string
-
(Required) Date string to parse and format.
Return
(string) Date formatted for ISO8601 without time zone.
Source
File: wp-includes/functions.php
function mysql_to_rfc3339( $date_string ) {
$formatted = mysql2date( 'c', $date_string, false );
// Strip timezone information
return preg_replace( '/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted );
}
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |