當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTime::convertFormatToPhp方法代碼示例

本文整理匯總了PHP中Bitrix\Main\Type\DateTime::convertFormatToPhp方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTime::convertFormatToPhp方法的具體用法?PHP DateTime::convertFormatToPhp怎麽用?PHP DateTime::convertFormatToPhp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bitrix\Main\Type\DateTime的用法示例。


在下文中一共展示了DateTime::convertFormatToPhp方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例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 = 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


注:本文中的Bitrix\Main\Type\DateTime::convertFormatToPhp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。