/** * 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. * * @param string $date Time value in format of YYYYMMDDHHIISS * @param string $format If gap is within a day, returns this format. * @return string */ function getTimeGap($date, $format = 'Y.m.d') { $timestamp = ztime($date); $gap = RX_TIME - $timestamp; if ($gap < 60 * 60 * 24) { return Rhymix\Framework\DateTime::getRelativeTimestamp($gap >= 60 ? $timestamp : RX_TIME - 60); } else { return zdate($date, $format); } }