• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/database.php
  • Класс: CAllDatabase
  • Вызов: CAllDatabase::DateToCharFunction
public function DateToCharFunction($strFieldName, $strType="FULL", $lang=false, $bSearchInSitesOnly=false)
{
	static $CACHE = array();

	$id = $strType . ',' . $lang . ',' . $bSearchInSitesOnly;
	if (!isset($CACHE[$id]))
	{
		if ($lang === false && ($context = Context::getCurrent()) && ($culture = $context->getCulture()) !== null)
		{
			$format = ($strType == "FULL" ? $culture->getFormatDatetime() : $culture->getFormatDate());
		}
		else
		{
			$format = CLang::GetDateFormat($strType, $lang, $bSearchInSitesOnly);
		}
		$CACHE[$id] = $this->DateFormatToDB($format);
	}

	$sFieldExpr = $strFieldName;

	//time zone
	if ($strType == "FULL" && CTimeZone::Enabled())
	{
		$diff = CTimeZone::GetOffset();

		if ($diff <> 0)
		{
			$sFieldExpr = $this->connection->getSqlHelper()->addSecondsToDateTime($diff, $strFieldName);
		}
	}

	return str_replace("#FIELD#", $sFieldExpr, $CACHE[$id]);
}