parameter of getReadableDate() is optional, add makeTsFromDate()

This commit is contained in:
Uwe Steinmann 2020-12-17 13:40:04 +01:00
parent efe6fe085d
commit d624b3c9ef

View File

@ -41,9 +41,11 @@ function getConvertDateFormat() {
return 'yyyy-mm-dd';
}
function getReadableDate($timestamp) { /* {{{ */
function getReadableDate($timestamp=0) { /* {{{ */
global $settings;
if(!is_numeric($timestamp))
if(!$timestamp)
$timestamp = time();
elseif(!is_numeric($timestamp))
$timestamp = strtotime($timestamp);
if($settings->_dateformat)
return date($settings->_dateformat, $timestamp);
@ -84,6 +86,16 @@ function getPeriodOfTime($timestamp) { /* {{{ */
}
} /* }}} */
/*
* Converts a date string into a timestamp
*
* @param $date string date in format understood by strftime
* @return integer/boolean unix timestamp or false in case of an error
*/
function makeTsFromDate($date) { /* {{{ */
return strtotime($date);
} /* }}} */
/*
* Converts a date/time string into a timestamp
*
@ -91,6 +103,7 @@ function getPeriodOfTime($timestamp) { /* {{{ */
* @return integer/boolean unix timestamp or false in case of an error
*/
function makeTsFromLongDate($date) { /* {{{ */
return strtotime($date);
$tmp = explode(' ', $date);
if(count($tmp) != 2)
return false;