• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/componenthelper.php
  • Класс: BitrixSocialnetworkComponentHelper
  • Вызов: ComponentHelper::formatDateTimeToGMT
static function formatDateTimeToGMT($dateTimeSource, $authorId): string
{
	if (empty($dateTimeSource))
	{
		return '';
	}

	$serverTs = MakeTimeStamp($dateTimeSource) - CTimeZone::getOffset();
	$serverGMTOffset = (int)date('Z');
	$authorOffset = (int)CTimeZone::getOffset($authorId);

	$authorGMTOffset = $serverGMTOffset + $authorOffset;
	$authorGMTOffsetFormatted = 'GMT';
	if ($authorGMTOffset !== 0)
	{
		$authorGMTOffsetFormatted .= ($authorGMTOffset >= 0 ? '+' : '-').sprintf('%02d', floor($authorGMTOffset / 3600)).':'.sprintf('%02u', ($authorGMTOffset % 3600) / 60);
	}

	return FormatDate(
			preg_replace('/[/.,s:][s]/', '', BitrixMainTypeDate::convertFormatToPhp(FORMAT_DATETIME)),
			($serverTs + $authorOffset)
		).' ('.$authorGMTOffsetFormatted.')';
}