diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php index 15d43be93..2d8a850f7 100644 --- a/inc/inc.Utils.php +++ b/inc/inc.Utils.php @@ -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