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


PHP DateTime::add方法代码示例

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


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

示例1: onBeforeAdd

 /**
  * @param Entity\Event $event
  * @return Entity\EventResult
  */
 public static function onBeforeAdd(Entity\Event $event)
 {
     $result = new Entity\EventResult();
     $data = $event->getParameter('fields');
     if (isset($data['TOKEN_EXPIRES_IN'])) {
         $dateTime = new Type\DateTime();
         $dateTime->add('+ ' . $data['TOKEN_EXPIRES_IN'] . ' sec');
         $result->modifyFields(['TOKEN_FINAL_DATE' => $dateTime]);
     }
     return $result;
 }
开发者ID:SidiGi,项目名称:shantilab.yandexdirect,代码行数:15,代码来源:accounts.php

示例2: getMap

 public static function getMap()
 {
     $date = new DateTime();
     $yesterday = Application::getConnection()->getSqlHelper()->getCharToDateFunction($date->add('-1 DAY')->format("Y-m-d H:i:s"));
     return array('ID' => array('data_type' => 'integer', 'primary' => true, 'autocomplete' => true), 'TOKEN' => array('data_type' => 'string', 'required' => true, 'validation' => array(__CLASS__, 'validateToken')), 'FILENAME' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateFilename')), 'CONTENT_TYPE' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateContentType')), 'PATH' => array('data_type' => 'string', 'required' => true, 'validation' => array(__CLASS__, 'validatePath')), 'BUCKET_ID' => array('data_type' => 'integer'), 'SIZE' => array('data_type' => 'integer'), 'WIDTH' => array('data_type' => 'integer'), 'HEIGHT' => array('data_type' => 'integer'), 'IS_CLOUD' => array('data_type' => 'boolean', 'values' => array(0, 1), 'default_value' => 0), 'IRRELEVANT' => array('data_type' => 'boolean', 'expression' => array("CASE WHEN (%s < {$yesterday}) THEN 1 ELSE 0 END", 'CREATE_TIME'), 'values' => array(0, 1)), 'CREATED_BY' => array('data_type' => 'integer'), 'CREATE_USER' => array('data_type' => 'Bitrix\\Main\\UserTable', 'reference' => array('=this.CREATED_BY' => 'ref.ID')), 'CREATE_TIME' => array('data_type' => 'datetime', 'required' => true, 'default_value' => new DateTime()));
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:6,代码来源:tmpfile.php

示例3: date

     $dateFormat = 'Y-m-d';
     $axisDateFormat = "D\nd.m";
     $axisCursorDateFormat = "l\nd M Y";
     break;
 case 'week':
     $fromDate = Type\DateTime::createFromTimestamp(mktime(0, 0, 0, date('n'), date('j') - 7));
     $interval = 'day';
     $dateFormat = 'Y-m-d';
     $axisDateFormat = "D\nd.m";
     $axisCursorDateFormat = "l\nd M Y";
     break;
 case 'custom_day':
     // for today, from 00:00 till 23:59
     $arParams['CUSTOM_DAY'] = isset($arParams['CUSTOM_DAY']) ? $arParams['CUSTOM_DAY'] : $_REQUEST['CUSTOM_DAY'];
     $fromDate = new Type\DateTime($arParams['CUSTOM_DAY'] . ' 00:00:00', 'Y-m-d H:i:s');
     $fromDate->add('-1 hour');
     $toDate = clone $fromDate;
     $toDate->add('+25 hour');
     $interval = 'hour';
     $dateFormat = 'Y-m-d H:00:00';
     $axisDateFormat = "H";
     $axisCursorDateFormat = "d M Y\n" . (IsAmPmMode() ? "g:i a" : "H:i");
     break;
 default:
     // for today, from 00:00 till 23:59
     $fromDate = Type\DateTime::createFromTimestamp(mktime(-1, 0, 0));
     $toDate = Type\DateTime::createFromTimestamp(mktime(24, 0, 0));
     $interval = 'hour';
     $dateFormat = 'Y-m-d H:00:00';
     $axisDateFormat = "H";
     $axisCursorDateFormat = array("today" => "today, " . (IsAmPmMode() ? "g:i a" : "H:i"));
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例4: deleteOld

 /**
  * @param int $days
  *
  * @return bool
  */
 public static function deleteOld($days)
 {
     $expired = new Main\Type\DateTime();
     $expired->add('-' . $days . 'days');
     $expiredValue = $expired->format('Y-m-d H:i:s');
     /** @var Main\DB\Connection $connection */
     $connection = Main\Application::getConnection();
     /** @var Main\DB\SqlHelper $sqlHelper */
     $sqlHelper = $connection->getSqlHelper();
     $sqlExpiredDate = $sqlHelper->getDateToCharFunction("'" . $expiredValue . "'");
     if ($connection instanceof Main\DB\MysqlCommonConnection) {
         $query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t SELECT ID FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\t\t\t \t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
         $connection->queryExecute($query);
         $query = "DELETE FROM b_sale_basket\tWHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
         $connection->queryExecute($query);
     } elseif ($connection instanceof Main\DB\MssqlConnection) {
         $query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n     \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE b_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)";
         $connection->queryExecute($query);
         $query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t)";
         $connection->queryExecute($query);
     } elseif ($connection instanceof Main\DB\OracleConnection) {
         $query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n     \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
         $connection->queryExecute($query);
         $query = "DELETE FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
         $connection->queryExecute($query);
     }
     return true;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:33,代码来源:basket.php

示例5: deleteOld

 /**
  * Delete fuserId over several days.
  *
  * @param int $days			Interval.
  * @return void
  */
 public static function deleteOld($days)
 {
     $expired = new Main\Type\DateTime();
     $expired->add('-' . $days . 'days');
     $expiredValue = $expired->format('Y-m-d H:i:s');
     /** @var Main\DB\Connection $connection */
     $connection = Main\Application::getConnection();
     /** @var Main\DB\SqlHelper $sqlHelper */
     $sqlHelper = $connection->getSqlHelper();
     $query = "DELETE FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlHelper->getDateToCharFunction("'" . $expiredValue . "'") . "\n\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\tAND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
     $connection->queryExecute($query);
 }
开发者ID:akniyev,项目名称:itprom_dobrohost,代码行数:18,代码来源:fuser.php

示例6: deleteOld

 /**
  * @param int $days
  *
  * @return bool
  */
 public static function deleteOld($days)
 {
     $connection = Main\Application::getConnection();
     $expired = new Main\Type\DateTime();
     $expired->add('-' . $days . 'days');
     $expiredValue = $expired->format('Y-m-d H:i:s');
     if ($connection instanceof Main\DB\MysqlConnection) {
         $query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t SELECT ID FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\t\t\t \t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < '" . $expiredValue . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
         $connection->query($query);
         $query = "DELETE FROM b_sale_basket\tWHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < '" . $expiredValue . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
         $connection->query($query);
     } elseif ($connection instanceof Main\DB\MssqlConnection) {
         $query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n     \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE b_sale_fuser.DATE_UPDATE < CONVERT(varchar(20),'" . $expiredValue . "', 20)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)";
         $connection->query($query);
         $query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < CONVERT(varchar(20),'" . $expiredValue . "', 20)\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t)";
         $connection->query($query);
     } elseif ($connection instanceof Main\DB\OracleConnection) {
         $query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID NOT IN (\n     \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < TO_DATE('" . $expiredValue . "', 'YYYY-MM-DD HH24:MI:SS')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
         $connection->query($query);
         $query = "DELETE FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < TO_DATE('" . $expiredValue . "', 'YYYY-MM-DD HH24:MI:SS')\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
         $connection->query($query);
     }
     return true;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:29,代码来源:basket.php

示例7: getDataForViewFile

 /**
  * Get url for showing preview file.
  * @param FileData $fileData
  * @return string|null
  */
 public function getDataForViewFile(FileData $fileData)
 {
     if (!$this->checkRequiredInputParams($fileData->toArray(), array('file'))) {
         return null;
     }
     $seconds = (int) 300;
     $deathTime = new DateTime();
     $deathTime->add("+ {$seconds} seconds");
     $data = array('TYPE' => ExternalLinkTable::TYPE_AUTO, 'DEATH_TIME' => $deathTime);
     $specificVersionModel = $fileData->getVersion();
     if ($specificVersionModel) {
         $data['VERSION_ID'] = $specificVersionModel->getId();
     }
     $extLinkModel = $fileData->getFile()->addExternalLink($data);
     if (!$extLinkModel) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_GOOGLE_VIEWER_HANDLER_ERROR_COULD_NOT_FIND_EXT_LINK'), self::ERROR_COULD_NOT_FIND_EXT_LINK)));
         $this->errorCollection->add($fileData->getFile()->getErrors());
     }
     $extLink = Driver::getInstance()->getUrlManager()->getUrlExternalLink(array('hash' => $extLinkModel->getHash(), 'action' => 'download'), true);
     return array('id' => $extLinkModel->getHash(), 'viewUrl' => Driver::getInstance()->getUrlManager()->generateUrlForGoogleViewer($extLink), 'neededDelete' => false, 'neededCheckView' => true);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:26,代码来源:googleviewerhandler.php

示例8: send

 /**
  * @param array $chain
  * @return void
  */
 protected static function send($chain)
 {
     // set send status
     if (empty($chain['ID'])) {
         return;
     }
     if (empty($chain['POSTING_ID'])) {
         if (empty(static::$postingId)) {
             return;
         }
         $updateFields['POSTING_ID'] = static::$postingId;
     }
     $updateFields = array();
     if ($chain['STATUS'] == MailingChainTable::STATUS_WAIT) {
         $autoSendTime = new \Bitrix\Main\Type\DateTime();
         $autoSendTime->add($chain['TIME_SHIFT'] . ' minutes');
         $updateFields['STATUS'] = MailingChainTable::STATUS_SEND;
         $updateFields['AUTO_SEND_TIME'] = $autoSendTime;
     } else {
         $updateFields['AUTO_SEND_TIME'] = $chain['AUTO_SEND_TIME'];
         $updateFields['STATUS'] = $chain['STATUS'];
     }
     if (count($updateFields) > 0) {
         MailingChainTable::update(array('ID' => $chain['ID']), $updateFields);
     }
 }
开发者ID:Hawkart,项目名称:megatv,代码行数:30,代码来源:triggermanager.php

示例9: deleteOld

 /**
  * @param $days
  */
 public static function deleteOld($days)
 {
     $connection = Main\Application::getConnection();
     $expired = new Main\Type\DateTime();
     $expired->add('-' . $days . 'days');
     $expiredValue = $expired->format('Y-m-d H:i:s');
     if ($connection instanceof Main\DB\MysqlConnection) {
         $query = "DELETE FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < '" . $expiredValue . "'\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
         $connection->query($query);
     } elseif ($connection instanceof Main\DB\MssqlConnection) {
         $query = "DELETE FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < CONVERT(varchar(20),'" . $expiredValue . "', 20)\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
         $connection->query($query);
     } elseif ($connection instanceof Main\DB\OracleConnection) {
         $query = "DELETE FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < TO_DATE('" . $expiredValue . "', 'YYYY-MM-DD HH24:MI:SS')\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
         $connection->query($query);
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:20,代码来源:fuser.php


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