当前位置: 首页>>代码示例>>PHP>>正文


PHP DateTime::setTime方法代码示例

本文整理汇总了PHP中Bitrix\Main\Type\DateTime::setTime方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::setTime方法的具体用法?PHP DateTime::setTime怎么用?PHP DateTime::setTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bitrix\Main\Type\DateTime的用法示例。


在下文中一共展示了DateTime::setTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseDateString

 public static function parseDateString($str)
 {
     if ($str === '') {
         return null;
     }
     try {
         $date = new Date($str, Date::convertFormatToPhp(FORMAT_DATE));
     } catch (Main\ObjectException $e) {
         try {
             $date = new DateTime($str, Date::convertFormatToPhp(FORMAT_DATETIME));
             $date->setTime(0, 0, 0);
         } catch (Main\ObjectException $e) {
             return null;
         }
     }
     return $date;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:17,代码来源:dealstagehistoryentry.php

示例2: register

 /**
  * @return boolean
  */
 public static function register($ownerID, array $entityFields = null, array $options = null)
 {
     if (!is_int($ownerID)) {
         $ownerID = (int) $ownerID;
     }
     if ($ownerID <= 0) {
         throw new Main\ArgumentException('Owner ID must be greater than zero.', 'ownerID');
     }
     if (!is_array($options)) {
         $options = array();
     }
     $date = isset($options['DATE']) ? $options['DATE'] : null;
     if ($date === null) {
         $date = new Date();
     }
     $day = (int) $date->format('d');
     $month = (int) $date->format('m');
     $quarter = $month <= 3 ? 1 : ($month <= 6 ? 2 : ($month <= 9 ? 3 : 4));
     $year = (int) $date->format('Y');
     if (!is_array($entityFields)) {
         $dbResult = \CCrmDeal::GetListEx(array(), array('=ID' => $ownerID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('STAGE_ID', 'ASSIGNED_BY_ID', 'BEGINDATE', 'CLOSEDATE'));
         $entityFields = is_object($dbResult) ? $dbResult->Fetch() : null;
         if (!is_array($entityFields)) {
             return false;
         }
     }
     $stageID = isset($entityFields['STAGE_ID']) ? $entityFields['STAGE_ID'] : '';
     $semanticID = \CCrmDeal::GetSemanticID($stageID);
     $isLost = PhaseSemantics::isLost($semanticID);
     $responsibleID = isset($entityFields['ASSIGNED_BY_ID']) ? (int) $entityFields['ASSIGNED_BY_ID'] : 0;
     $callQty = 0;
     $meetingQty = 0;
     $emailQty = 0;
     $startTime = new DateTime($date->format(DateTime::getFormat()));
     $endTime = new DateTime($date->format(DateTime::getFormat()));
     $endTime->setTime(23, 59, 59);
     $query = new Query(Crm\ActivityTable::getEntity());
     $query->addSelect('TYPE_ID');
     $query->registerRuntimeField('', new ExpressionField('QTY', 'COUNT(*)'));
     $query->addSelect('QTY');
     $query->addFilter('=COMPLETED', 'Y');
     $query->addFilter('>=DEADLINE', $startTime);
     $query->addFilter('<=DEADLINE', $endTime);
     $query->addGroup('TYPE_ID');
     $subQuery = new Query(Crm\ActivityBindingTable::getEntity());
     $subQuery->addSelect('ACTIVITY_ID');
     $subQuery->addFilter('=OWNER_TYPE_ID', \CCrmOwnerType::Deal);
     $subQuery->addFilter('=OWNER_ID', $ownerID);
     $query->registerRuntimeField('', new ReferenceField('B', Base::getInstanceByQuery($subQuery), array('=this.ID' => 'ref.ACTIVITY_ID'), array('join_type' => 'INNER')));
     $dbResult = $query->exec();
     while ($stats = $dbResult->fetch()) {
         $typeID = isset($stats['TYPE_ID']) ? (int) $stats['TYPE_ID'] : 0;
         $qty = isset($stats['QTY']) ? (int) $stats['QTY'] : 0;
         if ($typeID === \CCrmActivityType::Call) {
             $callQty = $qty;
         } elseif ($typeID === \CCrmActivityType::Meeting) {
             $meetingQty = $qty;
         } elseif ($typeID === \CCrmActivityType::Email) {
             $emailQty = $qty;
         }
     }
     if ($callQty === 0 && $meetingQty === 0 && $emailQty === 0) {
         DealActivityStatisticsTable::delete(array('OWNER_ID' => $ownerID, 'DEADLINE_DATE' => $date));
         return true;
     }
     $present = self::get($ownerID, $date);
     if (is_array($present)) {
         if ($responsibleID === (int) $present['RESPONSIBLE_ID'] && $stageID === $present['STAGE_ID'] && $callQty === (int) $present['CALL_QTY'] && $meetingQty === (int) $present['MEETING_QTY'] && $emailQty === (int) $present['EMAIL_QTY']) {
             return false;
         }
         if ($responsibleID !== (int) $present['RESPONSIBLE_ID']) {
             DealActivityStatisticsTable::synchronize($ownerID, array('RESPONSIBLE_ID' => $responsibleID));
         }
     }
     $data = array('OWNER_ID' => $ownerID, 'DEADLINE_DATE' => $date, 'DEADLINE_YEAR' => $year, 'DEADLINE_QUARTER' => $quarter, 'DEADLINE_MONTH' => $month, 'DEADLINE_DAY' => $day, 'RESPONSIBLE_ID' => $responsibleID, 'STAGE_SEMANTIC_ID' => $semanticID, 'STAGE_ID' => $stageID, 'IS_LOST' => $isLost ? 'Y' : 'N', 'CALL_QTY' => $callQty, 'MEETING_QTY' => $meetingQty, 'EMAIL_QTY' => $emailQty);
     DealActivityStatisticsTable::upsert($data);
     return true;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:81,代码来源:dealactivitystatisticentry.php


注:本文中的Bitrix\Main\Type\DateTime::setTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。