本文整理汇总了PHP中Bitrix\Main\Type\DateTime类的典型用法代码示例。如果您正苦于以下问题:PHP DateTime类的具体用法?PHP DateTime怎么用?PHP DateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: getDateTimeToDbFunction
public function getDateTimeToDbFunction(\Bitrix\Main\Type\DateTime $value, $type = \Bitrix\Main\Type\DateTime::DATE_WITH_TIME)
{
$customOffset = $value->getOffset();
$serverTime = new \Bitrix\Main\Type\DateTime();
$serverOffset = $serverTime->getOffset();
$diff = $customOffset - $serverOffset;
$valueTmp = clone $value;
$valueTmp->sub(new \DateInterval(sprintf("PT%sS", $diff)));
$format = $type == \Bitrix\Main\Type\DateTime::DATE_WITHOUT_TIME ? "Y-m-d" : "Y-m-d H:i:s";
$date = "CONVERT(datetime, '" . $valueTmp->format($format) . "', 120)";
return $date;
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:12,代码来源:mssqlsqlhelper.php
示例3: convertTo
/**
* @param FieldType $fieldType Document field type.
* @param mixed $value Field value.
* @param string $toTypeClass Type class name.
* @return null|mixed
*/
public static function convertTo(FieldType $fieldType, $value, $toTypeClass)
{
/** @var Base $toTypeClass */
$type = $toTypeClass::getType();
switch ($type) {
case FieldType::BOOL:
$value = (bool) $value ? 'Y' : 'N';
break;
case FieldType::DATE:
$value = date(Main\Type\Date::convertFormatToPhp(\FORMAT_DATE), (int) $value);
break;
case FieldType::DATETIME:
$value = date(Main\Type\DateTime::convertFormatToPhp(\FORMAT_DATETIME), (int) $value);
break;
case FieldType::DOUBLE:
$value = (double) $value;
break;
case FieldType::INT:
$value = (int) $value;
break;
case FieldType::STRING:
case FieldType::TEXT:
$value = (string) $value;
break;
case FieldType::USER:
$value = 'user_' . (int) $value;
break;
default:
$value = null;
}
return $value;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:38,代码来源:double.php
示例4: convertTo
/**
* @param FieldType $fieldType Document field type.
* @param mixed $value Field value.
* @param string $toTypeClass Type class name.
* @return null|mixed
*/
public static function convertTo(FieldType $fieldType, $value, $toTypeClass)
{
/** @var Base $toTypeClass */
$type = $toTypeClass::getType();
switch ($type) {
case FieldType::DOUBLE:
case FieldType::INT:
$value = $value ? (int) strtotime($value) : 0;
break;
case FieldType::DATE:
$value = date(Type\Date::convertFormatToPhp(\FORMAT_DATE), strtotime($value));
break;
case FieldType::DATETIME:
$value = date(Type\DateTime::convertFormatToPhp(\FORMAT_DATETIME), strtotime($value));
break;
case FieldType::STRING:
case FieldType::TEXT:
$value = (string) $value;
if ($value) {
$format = static::getType() == FieldType::DATE ? \FORMAT_DATE : \FORMAT_DATETIME;
$value = date(Type\DateTime::convertFormatToPhp($format), strtotime($value));
}
break;
default:
$value = null;
}
return $value;
}
开发者ID:k-kalashnikov,项目名称:geekcon,代码行数:34,代码来源:date.php
示例5: onGenerateInitialData
public static function onGenerateInitialData(Date $from, Date $to)
{
$data = array();
// 1. Payments
$result = \CSaleOrder::GetList(array(), array('PAYED' => 'Y', 'CANCELED' => 'N', '>=DATE_PAYED' => $from, '<=DATE_PAYED' => $to), false, false, array('LID', 'DATE_PAYED', 'PRICE', 'CURRENCY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_PAYED']);
$sum = Config::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_payment_add_day'] += 1;
$counters['sale_payment_sum_add'] += $sum;
} else {
$counters = array('sale_payment_add_day' => 1, 'sale_payment_sum_add' => $sum);
}
}
// 2. Orders
$result = \CSaleOrder::GetList(array(), array('CANCELED' => 'N', '>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_INSERT']);
$sum = Config::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_order_add_day'] += 1;
$counters['sale_order_sum_add'] += $sum;
} else {
$counters = array('sale_order_add_day' => 1, 'sale_order_sum_add' => $sum);
}
}
// 3. Cart
$result = \CSaleBasket::GetList(array(), array('>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY', 'QUANTITY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_INSERT']);
$sum = Config::convertToBaseCurrency($row['PRICE'] * $row['QUANTITY'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_cart_add_day'] += 1;
$counters['sale_cart_sum_add'] += $sum;
} else {
$counters = array('sale_cart_add_day' => 1, 'sale_cart_sum_add' => $sum);
}
}
// Result
unset($counters);
$result = array();
foreach ($data as $siteId => $dayCounters) {
$result[] = array('ATTRIBUTES' => array('conversion_site' => $siteId), 'DAY_COUNTERS' => $dayCounters);
}
return $result;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:47,代码来源:conversionhandlers.php
示例6: passed
/**
* Возвращает дату в формате прошедшего времени. Например, "15 минут назад", "2 часа назад", "вчера", ...
* @param \Bitrix\Main\Type\DateTime $datetime
* @return string
*/
public static function passed(\Bitrix\Main\Type\DateTime $datetime, $formatDateTime = 'd.m.Y H:i', $formatDay = 'H:i')
{
$time = $datetime->getTimestamp();
$diff = time() - $time;
//
if (self::passedYesterday($time, $output)) {
return $output;
} elseif ($diff < 60) {
return "только что";
} elseif ($diff < 60 * 60) {
return self::passedMinutes(0, $diff);
} elseif ($diff < 60 * 60 * 24) {
return self::passedHours(0, $diff);
} else {
return $datetime->format($formatDateTime);
}
}
开发者ID:irpsv,项目名称:juggernaut.bitrix,代码行数:22,代码来源:DateTime.php
示例7: generateInitialData
public static function generateInitialData(Date $from)
{
if (($to = Option::get('conversion', 'START_DATE_TIME', 'undefined')) != 'undefined' && DateTime::isCorrect($to, 'Y-m-d H:i:s') && ($to = new DateTime($to, 'Y-m-d H:i:s')) && $to->format('Y-m-d H:i:s') > $from->format('Y-m-d H:i:s') && Option::get('conversion', 'GENERATE_INITIAL_DATA', 'undefined') == 'undefined') {
Option::set('conversion', 'GENERATE_INITIAL_DATA', 'generated');
$context = new self();
// generate data
$data = array();
foreach (EventManager::getInstance()->findEventHandlers('conversion', 'OnGenerateInitialData') as $handler) {
$result = ExecuteModuleEventEx($handler, array($from, $to));
// TODO validate
foreach ($result as $row) {
$context->id = null;
$context->attributes = array();
$context->setAttributes($row['ATTRIBUTES']);
$context->save();
if ($dayCounters =& $data[$context->id]) {
self::appendDayCounters($dayCounters, $row['DAY_COUNTERS']);
} else {
$dayCounters = $row['DAY_COUNTERS'];
}
}
}
unset($dayCounters);
// save data to database
$numerators = CounterManager::getTypes(array('GROUP' => 'day'));
unset($numerators['conversion_visit_day']);
foreach ($data as $id => $dayCounters) {
$context->id = $id;
foreach ($dayCounters as $day => $counters) {
$day = new Date($day, 'Y-m-d');
$visitSum = 0;
$visitQuantity = 0;
unset($counters['conversion_visit_day']);
foreach ($counters as $name => $value) {
$context->addCounter($day, $name, $value);
if ($numerators[$name]) {
$visitSum += $value;
$visitQuantity += 1;
}
}
$context->addCounter($day, 'conversion_visit_day', $visitQuantity ? round($visitSum / $visitQuantity * 100) + 1 : 1);
}
}
}
}
开发者ID:Satariall,项目名称:izurit,代码行数:45,代码来源:generatorcontext.php
示例8: externalize
public function externalize()
{
$result = array('srcEntityTypeID' => $this->srcEntityTypeID, 'dstEntityTypeID' => $this->dstEntityTypeID, 'time' => $this->time->format(\DateTime::ISO8601), 'items' => array());
if ($this->srcIndex !== null) {
foreach ($this->srcIndex as $item) {
$result['items'][] = $item->externalize();
}
}
return $result;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:10,代码来源:entityconversionmap.php
示例9: 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;
}
开发者ID:ASDAFF,项目名称:bitrix-module-migrations,代码行数:14,代码来源:appliedchangeslogmodel.php
示例10: convertTo
/**
* @param FieldType $fieldType Document field type.
* @param mixed $value Field value.
* @param string $toTypeClass Type class name.
* @return null|mixed
*/
public static function convertTo(FieldType $fieldType, $value, $toTypeClass)
{
/** @var Base $toTypeClass */
$type = $toTypeClass::getType();
switch ($type) {
case FieldType::BOOL:
$value = strtolower((string) $value);
$value = in_array($value, array('y', 'yes', 'true', '1')) ? 'Y' : 'N';
break;
case FieldType::DATE:
$value = date(Main\Type\Date::convertFormatToPhp(\FORMAT_DATE), strtotime($value));
break;
case FieldType::DATETIME:
$value = date(Main\Type\DateTime::convertFormatToPhp(\FORMAT_DATETIME), strtotime($value));
break;
case FieldType::DOUBLE:
$value = str_replace(' ', '', str_replace(',', '.', $value));
$value = (double) $value;
break;
case FieldType::INT:
$value = str_replace(' ', '', $value);
$value = (int) $value;
break;
case FieldType::STRING:
case FieldType::TEXT:
$value = (string) $value;
break;
case FieldType::USER:
$value = trim($value);
if (strpos($value, 'user_') === false && strpos($value, 'group_') === false && !preg_match('#^[0-9]+$#', $value)) {
$value = null;
}
break;
default:
$value = null;
}
return $value;
}
开发者ID:k-kalashnikov,项目名称:geekcon,代码行数:44,代码来源:string.php
示例11: fixColdStart
/**
* Fixes cold start, when we don't have any data in RecentlyUsedTable.
* @param mixed|int|User|\CAllUser $user User.
* @return bool
* @throws \Bitrix\Main\ArgumentException
*/
private function fixColdStart($user)
{
$userId = User::resolveUserId($user);
if (!$userId) {
$this->errorCollection->addOne(new Error('Could not get user id.'));
return false;
}
$storage = Driver::getInstance()->getStorageByUserId($userId);
if (!$storage) {
$this->errorCollection->addOne(new Error('Could not get storage by user id.'));
return false;
}
$fromDate = DateTime::createFromTimestamp(time() - 14 * 24 * 3600);
$objects = array();
$query = FileTable::getList(array('select' => array('ID', 'UPDATE_TIME'), 'filter' => array('STORAGE_ID' => $storage->getId(), 'TYPE' => ObjectTable::TYPE_FILE, 'DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE, '>UPDATE_TIME' => $fromDate, array('LOGIC' => 'OR', array('CREATED_BY' => $userId), array('UPDATED_BY' => $userId))), 'order' => array('UPDATE_TIME' => 'DESC'), 'limit' => RecentlyUsedTable::MAX_COUNT_FOR_USER));
while ($row = $query->fetch()) {
$objects[] = array('USER_ID' => $userId, 'OBJECT_ID' => $row['ID'], 'CREATE_TIME' => $row['UPDATE_TIME']);
}
unset($row, $query, $fromDate);
Collection::sortByColumn($objects, array('CREATE_TIME' => SORT_ASC));
RecentlyUsedTable::insertBatch($objects);
return true;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:29,代码来源:recentlyusedmanager.php
示例12: getHourlyCompanyActivitySince
protected static function getHourlyCompanyActivitySince(Type\DateTime $hour = null)
{
$query = new Entity\Query('Bitrix\\Intranet\\UStat\\UserHourTable');
// set all activity columns
$uStatFields = UserHourTable::getEntity()->getFields();
foreach ($uStatFields as $uStatField) {
if ($uStatField instanceof Entity\ScalarField && !$uStatField->isPrimary()) {
$query->addSelect(new Entity\ExpressionField($uStatField->getName() . '_SUM', 'SUM(%s)', $uStatField->getName()));
}
}
// add & automatically group by hour
$query->addSelect('HOUR');
// add filter by date
if ($hour !== null) {
$query->setFilter(array('>=HOUR' => \ConvertTimeStamp($hour->getTimestamp(), 'FULL')));
}
// collect activity
$activity = array();
$result = $query->exec();
while ($row = $result->fetch()) {
foreach ($row as $k => $v) {
if (substr($k, -4) === '_SUM') {
$row[substr($k, 0, -4)] = $v;
unset($row[$k]);
}
}
$activity[] = $row;
}
return $activity;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:30,代码来源:ustat.php
示例13:
if ($arParams["ADD_SECTIONS_CHAIN"] && !empty($arResult["SECTION"]["PATH"]) && is_array($arResult["SECTION"]["PATH"]))
{
foreach($arResult["SECTION"]["PATH"] as $arPath)
{
if ($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"] != "")
$APPLICATION->AddChainItem($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"], $arPath["~SECTION_PAGE_URL"]);
else
$APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);
}
}
if ($arParams["ADD_ELEMENT_CHAIN"])
{
if ($arResult["IPROPERTY_VALUES"]["ELEMENT_PAGE_TITLE"] != "")
$APPLICATION->AddChainItem($arResult["IPROPERTY_VALUES"]["ELEMENT_PAGE_TITLE"]);
else
$APPLICATION->AddChainItem($arResult["NAME"]);
}
if ($arParams["SET_LAST_MODIFIED"] && $arResult["TIMESTAMP_X"])
{
Context::getCurrent()->getResponse()->setLastModified(DateTime::createFromUserTime($arResult["TIMESTAMP_X"]));
}
return $arResult["ID"];
}
else
{
return 0;
}
?>
开发者ID:CheBurashka334,项目名称:zakrepi,代码行数:30,代码来源:component.php
示例14: onBeforeSave
/**
* @param array $userfield
* @param Type\Date|string $value
*
* @return Type\Date
*/
public function onBeforeSave($userfield, $value)
{
if (strlen($value) && !$value instanceof Type\Date) {
// try both site's format - short and full
try {
$value = new Type\Date($value);
} catch (Main\ObjectException $e) {
$value = new Type\Date($value, Type\DateTime::getFormat());
}
}
return $value;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:18,代码来源:usertypedate.php
示例15: SearchDateChatMessage
function SearchDateChatMessage($searchDate, $chatId, $bTimeZone = true)
{
global $DB;
$chatId = IntVal($chatId);
$sqlHelper = Bitrix\Main\Application::getInstance()->getConnection()->getSqlHelper();
try {
$dateStart = \Bitrix\Main\Type\DateTime::createFromUserTime($searchDate);
$sqlDateStart = $sqlHelper->getCharToDateFunction($dateStart->format("Y-m-d H:i:s"));
$dateEnd = $dateStart->add('1 DAY');
$sqlDateEnd = $sqlHelper->getCharToDateFunction($dateEnd->format("Y-m-d H:i:s"));
} catch (\Bitrix\Main\ObjectException $e) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_HISTORY_SEARCH_DATE_EMPTY"), "ERROR_SEARCH_EMPTY");
return false;
}
$limitById = '';
$ar = \CIMChat::GetRelationById($chatId, $this->user_id);
if ($ar && $ar['START_ID'] > 0) {
$limitById = 'AND M.ID >= ' . intval($ar['START_ID']);
}
if (!$bTimeZone) {
CTimeZone::Disable();
}
$strSql = "\n\t\t\tSELECT\n\t\t\t\tM.ID,\n\t\t\t\tM.CHAT_ID,\n\t\t\t\tM.MESSAGE,\n\t\t\t\t" . $DB->DatetimeToTimestampFunction('M.DATE_CREATE') . " DATE_CREATE,\n\t\t\t\tM.AUTHOR_ID\n\t\t\tFROM b_im_relation R1\n\t\t\tINNER JOIN b_im_message M ON M.CHAT_ID = R1.CHAT_ID\n\t\t\tWHERE\n\t\t\t\tR1.USER_ID = " . $this->user_id . "\n\t\t\tAND R1.CHAT_ID = " . $chatId . "\n\t\t\tAND R1.MESSAGE_TYPE <> '" . IM_MESSAGE_PRIVATE . "'\n\t\t\tAND M.DATE_CREATE >= " . $sqlDateStart . " AND M.DATE_CREATE <= " . $sqlDateEnd . "\n\t\t\t\t" . $limitById . "\n\t\t\tORDER BY M.DATE_CREATE DESC, M.ID DESC\n\t\t";
if (!$bTimeZone) {
CTimeZone::Enable();
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$arMessages = array();
$arMessageId = array();
$arUnreadMessage = array();
$usersMessage = array();
$CCTP = new CTextParser();
$CCTP->MaxStringLen = 200;
$CCTP->allow = array("HTML" => "N", "ANCHOR" => $this->bHideLink ? "N" : "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => $this->bHideLink ? "N" : "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
while ($arRes = $dbRes->Fetch()) {
$arMessages[$arRes['ID']] = array('id' => $arRes['ID'], 'chatId' => $arRes['CHAT_ID'], 'senderId' => $arRes['AUTHOR_ID'], 'recipientId' => $arRes['CHAT_ID'], 'date' => $arRes['DATE_CREATE'], 'text' => $CCTP->convertText(htmlspecialcharsbx($arRes['MESSAGE'])));
$usersMessage[$arRes['CHAT_ID']][] = $arRes['ID'];
$arMessageId[] = $arRes['ID'];
}
$params = CIMMessageParam::Get($arMessageId);
$arFiles = array();
foreach ($params as $messageId => $param) {
$arMessages[$messageId]['params'] = $param;
if (isset($param['FILE_ID'])) {
foreach ($param['FILE_ID'] as $fileId) {
$arFiles[$fileId] = $fileId;
}
}
}
$arMessageFiles = CIMDisk::GetFiles($chatId, $arFiles);
return array('chatId' => $chatId, 'message' => $arMessages, 'unreadMessage' => $arUnreadMessage, 'usersMessage' => $usersMessage, 'files' => $arMessageFiles);
}
开发者ID:Satariall,项目名称:izurit,代码行数:52,代码来源:im_history.php
示例16: setDefaultTimeZone
/**
* Sets default timezone.
*
* @return DateTime
*/
public function setDefaultTimeZone()
{
$time = new \DateTime();
$this->setTimezone($time->getTimezone());
return $this;
}
开发者ID:nycmic,项目名称:bittest,代码行数:11,代码来源:datetime.php
示例17: 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
示例18: FormatDate
/**
* <p>Преобразует дату из одного заданного формата в другой заданный формат. В формате допустимы следующие обозначения:</p> <p> </p> <table width="100%" class="tnormal"> <tr> <th width="40%">Обозначение</th> <th width="60%">Описание</th> </tr> <tr> <td>YYYY</td> <td>Год (0001 - 9999)</td> </tr> <tr> <td>MM</td> <td>Месяц (01 - 12)</td> </tr> <tr> <td>DD</td> <td>День (01 - 31)</td> </tr> <tr> <td>HH</td> <td>Часы (00 - 24)</td> </tr> <tr> <td>MI</td> <td>Минуты (00 - 59)</td> </tr> <tr> <td>SS</td> <td>Секунды (00 - 59)</td> </tr> </table> <p>Динамичный метод.</p>
*
*
* @param string $date Год (0001 - 9999)</b
*
* @param string $format = "DD.MM.YYYY Месяц (01 - 12)</bo
*
* @param H $H День (01 - 31)</b
*
* @param M $I Часы (00 - 24)</bo
*
* @param S $S Минуты (00 - 59)</b
*
* @param $string Секунды (00 - 59)</bod
*
* @param new_forma $t = "DD.MM.YYYY
*
* @param H $H Дата для конвертации.
*
* @param M $I Текущий формат даты. <br>Необязательный. По умолчанию - "DD.MM.YYYY HH:MI:SS".
*
* @param S $S В какой формат необходимо преобразовать. <br>Необязательный. По
* умолчанию - "DD.MM.YYYY HH:MI:SS".
*
* @return string
*
* <h4>Example</h4>
* <pre>
* <?
* // зададим дату
* $date = "31.12.2007";
*
* // укажем формат этой даты
* $format = "DD.MM.YYYY";
*
* // получим формат текущего сайта
* $new_format = CSite::GetDateFormat("SHORT"); // YYYY-MM-DD
*
* // переведем дату из одного формата в другой
* $new_date = $DB-><b>FormatDate</b>($date, $format, $new_format);
*
* // в результате получим дату в новом формате
* echo $new_date; // 2007-12-31
* ?>
*
*
* <?
* // конвертация даты из формата одного сайта в формат другого
*
* // получим формат сайта ru
* $format_ru = CSite::GetDateFormat("SHORT", "ru"); // DD.MM.YYYY
*
* // получим формат сайта en
* $format_en = CSite::GetDateFormat("SHORT", "en"); // YYYY-MM-DD
*
* // переведем дату из формата сайта ru в формат сайта en
* $new_date = $DB-><b>FormatDate</b>($date, $format_ru, $format_en);
*
* // в результате получим дату в новом формате
* echo $date; // 2007-12-31
* ?>
* </pre>
*
*
* <h4>See Also</h4>
* <ul> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/main/reference/cdatabase/dateformattophp.php">CDatabase::DateFormatToPHP</a>
* </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/csite/getdateformat.php">CSite::GetDateFormat</a>
* </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/date/convertdatetime.php">ConvertDateTime</a> </li>
* <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/date/index.php">Функции для работы с
* датой и временем</a> </li> </ul> <a name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/main/reference/cdatabase/formatdate.php
* @author Bitrix
*/
public static function FormatDate($strDate, $format = "DD.MM.YYYY HH:MI:SS", $new_format = "DD.MM.YYYY HH:MI:SS")
{
if (empty($strDate)) {
return false;
}
if ($format === false && defined("FORMAT_DATETIME")) {
$format = FORMAT_DATETIME;
}
$fromPhpFormat = Main\Type\Date::convertFormatToPhp($format);
$time = false;
try {
$time = new Main\Type\DateTime($strDate, $fromPhpFormat);
} catch (Main\ObjectException $e) {
}
if ($time !== false) {
//Compatibility issue
$fixed_format = preg_replace(array("/(?<!Y)Y(?!Y)/i", "/(?<!M)M(?!M|I)/i", "/(?<!D)D(?!D)/i", "/(?<!H)H:I:S/i"), array("YYYY", "MM", "DD", "HH:MI:SS"), strtoupper($new_format));
$toPhpFormat = Main\Type\Date::convertFormatToPhp($fixed_format);
return $time->format($toPhpFormat);
}
return false;
}
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:100,代码来源:database.php
示例19: ksort
ksort($params);
$check = base64_encode(sha1($key, implode("|", array_values($params))));
if ($check != $_SERVER['HTTP_X_API_SIGNATURE']) {
qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_AUTH);
}
} else {
qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_AUTH);
}
}
list($orderId, $paymentId) = explode(':', $_POST['bill_id']);
/** @var \Bitrix\Sale\Order $order */
$order = Order::load($orderId);
if ($order) {
$arOrder = $order->getFieldValues();
$payment = $order->getPaymentCollection()->getItemById($paymentId);
$paidInfo = array("PS_STATUS" => $_POST['status'] == "paid" ? "Y" : "N", "PS_STATUS_CODE" => substr($_POST['status'], 0, 5), "PS_STATUS_MESSAGE" => Loc::getMessage("SALE_QWH_STATUS_MESSAGE_" . strtoupper($_POST['status'])), "PS_RESPONSE_DATE" => \Bitrix\Main\Type\DateTime::createFromTimestamp(time()), "PS_SUM" => (double) $_POST['amount'], "PS_CURRENCY" => $_POST['ccy'], "PS_STATUS_DESCRIPTION" => "");
if ((int) $_POST['error']) {
$paidInfo['PS_STATUS_DESCRIPTION'] = "Error: " . Loc::getMessage("SALE_QWH_ERROR_CODE_" . $_POST['error']);
$payment->setFields($paidInfo);
qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_OTHER);
}
foreach ($_POST as $key => $value) {
$paidInfo['PS_STATUS_DESCRIPTION'] .= "{$key}:{$value}, ";
}
$payment->setFields($paidInfo);
$changeStatusPay = CSalePaySystemAction::GetParamValue("CHANGE_STATUS_PAY") == "Y";
if ($_POST['status'] == "paid" && $changeStatusPay) {
$resPayment = $payment->setField('PAID', 'Y');
if ($resPayment->isSuccess()) {
qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_NONE);
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:result_rec.php
示例20: LocalRedirect
CCurrency::updateAllCurrencyBaseRate();
LocalRedirect($APPLICATION->GetCurPage() . '?lang=' . LANGUAGE_ID . '&mid=' . $module_id . '&' . $systemTabControl->ActiveTabParam());
}
if (isset($_POST['agents']) && $_POST['agents'] == 'Y' && isset($_POST['action']) && !empty($_POST['action'])) {
$action = (string) $_POST['action'];
switch ($action) {
case 'activate':
case 'deactivate':
$agentIterator = CAgent::GetList(array(), array('MODULE_ID' => 'currency', '=NAME' => '\\Bitrix\\Currency\\CurrencyTable::currencyBaseRateAgent();'));
if ($currencyAgent = $agentIterator->Fetch()) {
$active = $action == 'activate' ? 'Y' : 'N';
CAgent::Update($currencyAgent['ID'], array('ACTIVE' => $active));
}
break;
case 'create':
$checkDate = DateTime::createFromTimestamp(strtotime('tomorrow 00:01:00'));
CAgent::AddAgent('\\Bitrix\\Currency\\CurrencyTable::currencyBaseRateAgent();', 'currency', 'Y', 86400, '', 'Y', $checkDate->toString(), 100, false, true);
break;
}
LocalRedirect($APPLICATION->GetCurPage() . '?lang=' . LANGUAGE_ID . '&mid=' . $module_id . '&' . $systemTabControl->ActiveTabParam());
}
}
$baseCurrency = Currency\CurrencyManager::getBaseCurrency();
$tabControl->Begin();
?>
<form method="POST" action="<?php
echo $APPLICATION->GetCurPage();
?>
?lang=<?php
echo LANGUAGE_ID;
?>
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:options.php
注:本文中的Bitrix\Main\Type\DateTime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论