- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/component_util.php
- Класс: CComponentUtil
- Вызов: CComponentUtil::GetDateTimeFormatted
static function GetDateTimeFormatted($timestamp, $dateTimeFormat = false, $offset = 0, $hideToday = false)
{
if (is_array($timestamp))
{
$params = $timestamp;
$timestamp = ($params['TIMESTAMP'] ?? false);
$offset = (isset($params['TZ_OFFSET']) ? intval($params['TZ_OFFSET']) : 0);
$hideToday = ($params['HIDE_TODAY'] ?? false);
}
if (empty($timestamp))
{
return '';
}
$culture = BitrixMainContext::getCurrent()->getCulture();
$timeFormat = $culture->getShortTimeFormat();
$dateTimeFormat = $culture->getLongDateFormat().' '.$timeFormat;
$dateTimeFormatWOYear = $culture->getDayMonthFormat().' '.$timeFormat;
$arFormat = array(
"tomorrow" => "tomorrow, ".$timeFormat,
"today" => ($hideToday ? $timeFormat : "today, ".$timeFormat),
"yesterday" => "yesterday, ".$timeFormat,
"" => (
date("Y", $timestamp) == date("Y")
? $dateTimeFormatWOYear
: $dateTimeFormat
)
);
return FormatDate($arFormat, $timestamp, (time() + $offset));
}