CCrmComponentHelper::RemoveSeconds

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmComponentHelper
  4. RemoveSeconds
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_component_helper.php
  • Класс: \CCrmComponentHelper
  • Вызов: CCrmComponentHelper::RemoveSeconds
static function RemoveSeconds($str, $options = null)
{
	$ary = array();
	if(preg_match('/(\d{1,2}):(\d{1,2}):(\d{1,2})/', $str, $ary, PREG_OFFSET_CAPTURE) !== 1)
	{
		return $str;
	}

	$time = "{$ary[1][0]}:{$ary[2][0]}";
	//Treat tail as part of time (AM/PM)
	$tailPos = $ary[3][1] + 2;
	if($tailPos < mb_strlen($str))
	{
		$time .= mb_substr($str, $tailPos);
	}
	$timeFormat = is_array($options) && isset($options['TIME_FORMAT']) ? strval($options['TIME_FORMAT']) : '';
	return mb_substr($str, 0, $ary[0][1]).($timeFormat === ''? $time : str_replace('#TIME#', $time, $timeFormat));
}

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