Definition:
function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {}
Converts MySQL DATETIME field to user specified date format.
If $dateformatstring has ‘G’ value, then gmmktime() function will be used to make the time. If $dateformatstring is set to ‘U’, then mktime() function will be used to make the time.
Parameters
- string $dateformatstring: Either ‘G’, ‘U’, or php date format.
- string $mysqlstring: Time from mysql DATETIME field.
- bool $translate: Optional. Default is true. Will switch format to locale.
Return values
returns:Date formatted by $dateformatstring or locale (if available).
Source code
function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
$m = $mysqlstring;
if ( empty( $m ) )
return false;
if ( 'G' == $dateformatstring )
return strtotime( $m . ' +0000' );
$i = strtotime( $m );
if ( 'U' == $dateformatstring )
return $i;
if ( $translate )
return date_i18n( $dateformatstring, $i );
else
return date( $dateformatstring, $i );
}
2419

February 12, 2011 


No comments yet... Be the first to leave a reply!