• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/database.php
  • Класс: CAllDatabase
  • Вызов: CAllDatabase::CharToDateFunction
public function CharToDateFunction($strValue, $strType="FULL", $lang=false)
{
	// get user time
	if ($strValue instanceof MainTypeDateTime && !$strValue->isUserTimeEnabled())
	{
		$strValue = clone $strValue;
		$strValue->toUserTime();
	}

	// format
	if ($lang === false && ($context = Context::getCurrent()) && ($culture = $context->getCulture()) !== null)
	{
		$format = ($strType == "FULL" ? $culture->getFormatDatetime() : $culture->getFormatDate());
	}
	else
	{
		$format = CLang::GetDateFormat($strType, $lang);
	}

	$sFieldExpr = "'".CDatabase::FormatDate($strValue, $format, ($strType=="SHORT"? "YYYY-MM-DD":"YYYY-MM-DD HH:MI:SS"))."'";

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

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

	return $sFieldExpr;
}