本文整理汇总了PHP中Bitrix\Main\Type\DateTime::createFromPhp方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::createFromPhp方法的具体用法?PHP DateTime::createFromPhp怎么用?PHP DateTime::createFromPhp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\Type\DateTime
的用法示例。
在下文中一共展示了DateTime::createFromPhp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyToDb
protected static function modifyToDb($data)
{
$result = array();
foreach ($data as $name => $value) {
if ($name == 'date' && $value instanceof \DateTime) {
$value = DateTime::createFromPhp($value);
}
if (in_array($name, array('originalData', 'updateData'))) {
$value = \WS\Migrations\arrayToJson($value);
}
$result[$name] = $value;
}
return $result;
}
示例2: checkPeriod
/**
* @return string
* @throws \Bitrix\Main\ArgumentException
*/
public static function checkPeriod($isAgentExec = true)
{
$isAgentExecInSetting = \COption::GetOptionString("sender", "reiterate_method") !== 'cron';
if ($isAgentExec && !$isAgentExecInSetting || !$isAgentExec && $isAgentExecInSetting) {
return "";
}
$dateTodayPhp = new \DateTime();
$datetimeToday = Type\DateTime::createFromPhp(clone $dateTodayPhp);
$dateToday = clone $dateTodayPhp;
$dateToday = Type\Date::createFromPhp($dateToday->setTime(0, 0, 0));
$dateTomorrow = clone $dateTodayPhp;
$dateTomorrow = Type\Date::createFromPhp($dateTomorrow->setTime(0, 0, 0))->add('1 DAY');
$arDateFilter = array($dateToday, $dateTomorrow);
$chainDb = MailingChainTable::getList(array('select' => array('ID', 'LAST_EXECUTED', 'POSTING_ID', 'DAYS_OF_MONTH', 'DAYS_OF_WEEK', 'TIMES_OF_DAY'), 'filter' => array('=REITERATE' => 'Y', '=MAILING.ACTIVE' => 'Y', 'STATUS' => MailingChainTable::STATUS_WAIT)));
while ($arMailingChain = $chainDb->fetch()) {
$lastExecuted = $arMailingChain['LAST_EXECUTED'];
/* @var \Bitrix\Main\Type\DateTime $lastExecuted*/
if ($lastExecuted && $lastExecuted->getTimestamp() >= $dateToday->getTimestamp()) {
continue;
}
$timeOfExecute = static::getDateExecute($dateTodayPhp, $arMailingChain["DAYS_OF_MONTH"], $arMailingChain["DAYS_OF_WEEK"], $arMailingChain["TIMES_OF_DAY"]);
if ($timeOfExecute) {
$arUpdateMailChain = array('LAST_EXECUTED' => $datetimeToday);
$postingDb = PostingTable::getList(array('select' => array('ID'), 'filter' => array('=MAILING_CHAIN_ID' => $arMailingChain['ID'], '><DATE_CREATE' => $arDateFilter)));
$arPosting = $postingDb->fetch();
if (!$arPosting) {
$postingId = MailingChainTable::initPosting($arMailingChain['ID']);
} else {
$postingId = $arPosting['ID'];
$arUpdateMailChain['POSTING_ID'] = $postingId;
PostingTable::initGroupRecipients($postingId);
}
if ($postingId) {
$arUpdateMailChain['STATUS'] = MailingChainTable::STATUS_SEND;
$arUpdateMailChain['AUTO_SEND_TIME'] = Type\DateTime::createFromPhp($timeOfExecute);
}
MailingChainTable::update(array('ID' => $arMailingChain['ID']), $arUpdateMailChain);
}
}
return static::getAgentNamePeriod();
}
示例3: modifyToDb
protected static function modifyToDb($data)
{
$data['date'] && $data['date'] instanceof \DateTime && ($data['date'] = DateTime::createFromPhp($data['date']));
return $data;
}