*/ class DateFormatter { /** * Formats the given timestamp in the 'day / month / year' format. * * @param int $timestamp * @return string * * @deprecated Use formatDMY() or formatDMYHM() instead */ public static function format($timestamp) { $format = "d / m / Y"; $date = date($format, $timestamp); return $date; } /** * Formats the given timestamp in the 'day / month / year at hour:minutes' * format. * * It checks that the date is not at midnight. If it is the case, it * doesn't display the hour:minutes part. * * @param int $timestamp * @return string */ public static function formatDMYHM($timestamp) { $format = "d / m / Y"; $date = date($format, $timestamp); $format = "H:i"; $hour = date($format, $timestamp); if ($hour == "00:00") { return $date; } else { return $date . " " . Localization::at . " " . $hour; } } /** * Formats the given timestamp in the 'day / month / year' format. * * @param int $timestamp * @return string */ public static function formatDMY($timestamp) { $format = "d / m / Y"; $date = date($format, $timestamp); return $date; } /** * Formats the given timestamp to a date following the RFC2822 ('r'). * * @param int $timestamp * @return string */ public static function formatRFC($timestamp) { $format = "r"; return date($format, $timestamp); } public static function formatSQL($timestamp) { return date("Y-m-d H:i:s", $timestamp); } public static function GetDMYForm($inputName, $timestamp) { $days = ""; $months = ""; $selectedYear = date("Y", $timestamp); $years = ""; $form = $days . " / " . $months . " / " . $years; return $form; } public static function getHHMMForm($inputName, $timestamp) { $hours = ""; $minutes = ""; $checked = ($selectedMinutes == 0 && $selectedHour == 0) ? "checked" : ""; $wholeDay = ""; $wholeDay .= ""; $form = $hours . " : " . $minutes . "
" . $wholeDay; return $form; } } ?>