Overhaul mysql2date() documentation and parameter names. See #20056.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19974 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ebc8ed6395
commit
5e653b76ed
|
@ -8,35 +8,37 @@
|
||||||
require( ABSPATH . WPINC . '/option.php' );
|
require( ABSPATH . WPINC . '/option.php' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts MySQL DATETIME field to user specified date format.
|
* Converts given date string into a different format.
|
||||||
*
|
*
|
||||||
* The $translate parameter will only be used, if it is set to true and it is by
|
* $format should be either a PHP date format string, e.g. 'U' for a Unix
|
||||||
* default and if the $wp_locale object has the month and weekday set.
|
* timestamp, or 'G' for a Unix timestamp assuming that $date is GMT.
|
||||||
|
*
|
||||||
|
* If $translate is true then the given date and format string will
|
||||||
|
* be passed to date_i18n() for translation.
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @since 0.71
|
||||||
*
|
*
|
||||||
* @param string $dateformatstring Either 'G', 'U', or PHP date format.
|
* @param string $format Format of the date to return.
|
||||||
* @param string $mysqlstring Time from mysql DATETIME field.
|
* @param string $date Date string to convert.
|
||||||
* @param bool $translate Optional. Default is true. Will switch format to locale.
|
* @param bool $translate Whether the return date should be translated. Default is true.
|
||||||
* @return string Date formatted by $dateformatstring or locale (if available).
|
* @return string|int Formatted date string, or Unix timestamp.
|
||||||
*/
|
*/
|
||||||
function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
|
function mysql2date( $format, $date, $translate = true ) {
|
||||||
$m = $mysqlstring;
|
if ( empty( $date ) )
|
||||||
if ( empty( $m ) )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( 'G' == $dateformatstring )
|
if ( 'G' == $format )
|
||||||
return strtotime( $m . ' +0000' );
|
return strtotime( $date . ' +0000' );
|
||||||
|
|
||||||
$i = strtotime( $m );
|
$i = strtotime( $date );
|
||||||
|
|
||||||
if ( 'U' == $dateformatstring )
|
if ( 'U' == $format )
|
||||||
return $i;
|
return $i;
|
||||||
|
|
||||||
if ( $translate )
|
if ( $translate )
|
||||||
return date_i18n( $dateformatstring, $i );
|
return date_i18n( $format, $i );
|
||||||
else
|
else
|
||||||
return date( $dateformatstring, $i );
|
return date( $format, $i );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue