mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-14 05:31:42 +00:00
getReadableDate() returns empty string if emptry string or null is passed
This commit is contained in:
parent
8d4492164d
commit
03cc220380
|
@ -41,12 +41,23 @@ function getConvertDateFormat() { /* {{{ */
|
||||||
return 'yyyy-mm-dd';
|
return 'yyyy-mm-dd';
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a human readable date string
|
||||||
|
*
|
||||||
|
* This function formats a timestamp according to the date format
|
||||||
|
* settings. If no timestamp is passed the current date is used.
|
||||||
|
* If null or an empty string is passed, then an empty string
|
||||||
|
* is returned. If $timestamp is numeric it will be taken as a unix
|
||||||
|
* timestamp. If $timestamp is a string it will be parѕed with strtotime().
|
||||||
|
*/
|
||||||
function getReadableDate($timestamp=0) { /* {{{ */
|
function getReadableDate($timestamp=0) { /* {{{ */
|
||||||
global $settings;
|
global $settings;
|
||||||
if(!$timestamp)
|
if($timestamp === 0)
|
||||||
$timestamp = time();
|
$timestamp = time();
|
||||||
elseif(!is_numeric($timestamp))
|
elseif($timestamp && is_string($timestamp))
|
||||||
$timestamp = strtotime($timestamp);
|
$timestamp = strtotime($timestamp);
|
||||||
|
elseif(!is_numeric($timestamp))
|
||||||
|
return '';
|
||||||
if($settings->_dateformat)
|
if($settings->_dateformat)
|
||||||
return date($settings->_dateformat, $timestamp);
|
return date($settings->_dateformat, $timestamp);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user