is::castToDateTimeGmt

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. is
  4. castToDateTimeGmt
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/util/scheduler.php
  • Класс: Bitrix\Tasks\Util\is
  • Вызов: is::castToDateTimeGmt
static function castToDateTimeGmt($date)
{
	if($date == null)
	{
		return null;
	}

	if(is_string($date))
	{
		// $date is treated as LOCAL TIME, since we have no information about time zone
		return DateTime::createFromUserTimeGmt($date);
	}
	elseif($date instanceof \Bitrix\Main\Type\DateTime)
	{
		// to local time ...
		$date = $date->toString();

		// .. and return as gmt
		return DateTime::createFromUserTimeGmt($date);
	}
	else
	{
		throw new \Bitrix\Main\ArgumentException('Unsupported type of date');
	}
}

Добавить комментарий