Add getInternalDateTime() and getDisplayDateTime() functions

This commit is contained in:
Kijin Sung 2016-02-12 09:09:27 +09:00
parent b7c921bd0a
commit a75eb80f8e

View file

@ -602,6 +602,32 @@ function zdate($str, $format = 'Y-m-d H:i:s', $conversion = false)
return $result;
}
/**
* Convert a Unix timestamp to YYYYMMDDHHIISS format, using the internal time zone.
* If the timestamp is not given, the current time is used.
*
* @param int $timestamp Unix timestamp
* @return string
*/
function getInternalDateTime($timestamp = null, $format = 'YmdHis')
{
$timestamp = ($timestamp !== null) ? $timestamp : time();
return Rhymix\Framework\DateTime::formatTimestamp($format, $timestamp);
}
/**
* Convert a Unix timestamp to YYYYMMDDHHIISS format, using the internal time zone.
* If the timestamp is not given, the current time is used.
*
* @param int $timestamp Unix timestamp
* @return string
*/
function getDisplayDateTime($timestamp = null, $format = 'YmdHis')
{
$timestamp = ($timestamp !== null) ? $timestamp : time();
return Rhymix\Framework\DateTime::formatTimestampForCurrentUser($format, $timestamp);
}
/**
* If the recent post within a day, output format of YmdHis is "min/hours ago from now". If not within a day, it return format string.
*