REST API: add a utility function, `mysql_to_rfc3339()` to `functions.php`

Background:
6d0ad766ca

Props rmmcue.
See #33982.

Built from https://develop.svn.wordpress.org/trunk@34846


git-svn-id: http://core.svn.wordpress.org/trunk@34811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-10-06 03:19:25 +00:00
parent f8c3aca01c
commit 0c6ee34d00
2 changed files with 22 additions and 4 deletions

View File

@ -5022,3 +5022,21 @@ function wp_post_preview_js() {
</script>
<?php
}
/**
* 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 );
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34845';
$wp_version = '4.4-alpha-34846';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.