/** * Formats any date needed for accessible. * * @param int $dateParam timestamp int. * @param boolean $setCompleteFormat specify a format. * @return string formatted date. */ public static function getFormattedDate($dateParam, $setCompleteFormat = false) { if (!isset($dateParam) || !is_int($dateParam)) { return ''; } $timeReceived = date('H:i', $dateParam); $dayReceived = date('d/m/Y', $dateParam); $weekDayReceived = DateUtils::getWeekDay($dateParam); if ($setCompleteFormat) { return $weekDayReceived . ', ' . $dayReceived . ', ' . $timeReceived; } if ($dateParam >= strtotime('today 00:00')) { return date('\\h\\o\\j\\e, H:i', $dateParam); } elseif ($dateParam >= strtotime('yesterday 00:00')) { return 'ontem, ' . $timeReceived; } elseif ($dateParam >= strtotime('-6 day 00:00')) { return $weekDayReceived . ', ' . $timeReceived; } else { return date('d/m/Y', $dateParam); } }