getReadableDate() returns empty string if emptry string or null is passed

This commit is contained in:
Uwe Steinmann 2022-04-29 18:29:17 +02:00
parent 8d4492164d
commit 03cc220380

View File

@ -41,12 +41,23 @@ function getConvertDateFormat() { /* {{{ */
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) { /* {{{ */
global $settings;
if(!$timestamp)
if($timestamp === 0)
$timestamp = time();
elseif(!is_numeric($timestamp))
elseif($timestamp && is_string($timestamp))
$timestamp = strtotime($timestamp);
elseif(!is_numeric($timestamp))
return '';
if($settings->_dateformat)
return date($settings->_dateformat, $timestamp);
else