• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/db/mysqlisqlhelper.php
  • Класс: BitrixMainDBMysqliSqlHelper
  • Вызов: MysqliSqlHelper::formatDate
public function formatDate($format, $field = null)
{
	static $search  = array(
		"YYYY",
		"MMMM",
		"MM",
		"MI",
		"DD",
		"HH",
		"GG",
		"G",
		"SS",
		"TT",
		"T"
	);
	static $replace = array(
		"%Y",
		"%M",
		"%m",
		"%i",
		"%d",
		"%H",
		"%h",
		"%l",
		"%s",
		"%p",
		"%p"
	);

	$format = str_replace($search, $replace, $format);

	if (!str_contains($format, '%H'))
	{
		$format = str_replace("H", "%h", $format);
	}

	if (!str_contains($format, '%M'))
	{
		$format = str_replace("M", "%b", $format);
	}

	if($field === null)
	{
		return $format;
	}
	else
	{
		return "DATE_FORMAT(".$field.", '".$format."')";
	}
}