• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/type/date.php
  • Класс: BitrixMainTypeDate
  • Вызов: Date::__construct
public function __construct($date = null, $format = null)
{
	$this->value = new DateTime();
	if ($date !== null && $date !== "")
	{
		if ($format === null)
		{
			$format = static::getFormat();
		}

		$parsedValue = $this->parse($format, $date);

		if($parsedValue === false)
		{
			throw new MainObjectException("Incorrect date: ".$date);
		}

		if(isset($parsedValue["timestamp"]))
		{
			$this->value->setTimestamp($parsedValue["timestamp"]);
		}
		else
		{
			$this->value->setDate($parsedValue['year'], $parsedValue['month'], $parsedValue['day']);
  			}
	}
	$this->value->setTime(0, 0);
}