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


PHP DateTimeUtil::convertTimestampToDbFormatDate方法代码示例

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


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

示例1: sanitizeValue

 /**
  * Given a value, attempt to convert the value to a db date format based on the format provided.  If the value
  * does not convert properly, meaning the value is not really in the format specified, then a
  * InvalidValueToSanitizeException will be thrown.
  * @param mixed $value
  * @return sanitized value
  * @throws InvalidValueToSanitizeException
  */
 public function sanitizeValue($value)
 {
     if ($value == null) {
         return $value;
     }
     $timeStamp = CDateTimeParser::parse($value, $this->mappingRuleData['format']);
     if ($timeStamp === false) {
         throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Invalid date format.'));
     }
     $dbDateValue = DateTimeUtil::convertTimestampToDbFormatDate($timeStamp);
     return $dbDateValue;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:20,代码来源:DateSanitizerUtil.php

示例2: sanitizeValue

 /**
  * Given a value, attempt to convert the value to a db date format based on the format provided.  If the value
  * does not convert properly, meaning the value is not really in the format specified, then a
  * InvalidValueToSanitizeException will be thrown.
  * @param string $modelClassName
  * @param string $attributeName
  * @param mixed $value
  * @param array $mappingRuleData
  */
 public static function sanitizeValue($modelClassName, $attributeName, $value, $mappingRuleData)
 {
     assert('is_string($modelClassName)');
     assert('is_string($attributeName)');
     assert('isset($mappingRuleData["format"])');
     if ($value == null) {
         return $value;
     }
     $timeStamp = CDateTimeParser::parse($value, $mappingRuleData['format']);
     if ($timeStamp === false) {
         throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Invalid date format.'));
     }
     $dbDateValue = DateTimeUtil::convertTimestampToDbFormatDate($timeStamp);
     return $dbDateValue;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:24,代码来源:DateSanitizerUtil.php

示例3: resolveValueAndSetToModel

 /**
  * Utilized to create or update model attribute values after a workflow's triggers are fired as true.
  * @param WorkflowActionProcessingModelAdapter $adapter
  * @param $attribute
  * @throws NotSupportedException
  */
 public function resolveValueAndSetToModel(WorkflowActionProcessingModelAdapter $adapter, $attribute)
 {
     assert('is_string($attribute)');
     if ($this->type == static::TYPE_STATIC) {
         $adapter->getModel()->{$attribute} = $this->value;
     } elseif ($this->type == self::TYPE_DYNAMIC_FROM_TRIGGERED_DATE) {
         $adapter->getModel()->{$attribute} = DateTimeUtil::convertTimestampToDbFormatDate(time() + $this->value);
     } elseif ($this->type == self::TYPE_DYNAMIC_FROM_EXISTING_DATE) {
         if (!DateTimeUtil::isDateStringNull($adapter->getModel()->{$attribute})) {
             $existingTimeStamp = DateTimeUtil::convertDbFormatDateTimeToTimestamp(DateTimeUtil::resolveDateAsDateTime($adapter->getModel()->{$attribute}));
             $newDate = DateTimeUtil::convertTimestampToDbFormatDate($existingTimeStamp + $this->value);
             $adapter->getModel()->{$attribute} = $newDate;
         }
     } else {
         throw new NotSupportedException();
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:23,代码来源:DateWorkflowActionAttributeForm.php

示例4: testDateResolveValueAndSetToModelUpdateAsDynamicFromTriggeredDate

 public function testDateResolveValueAndSetToModelUpdateAsDynamicFromTriggeredDate()
 {
     $form = new DateWorkflowActionAttributeForm('WorkflowsTestModule', 'WorkflowModelTestItem');
     $form->type = DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATE;
     $form->durationInterval = '1';
     $model = new WorkflowModelTestItem();
     $model->date = '1980-06-03';
     $adapter = new WorkflowActionProcessingModelAdapter($model, Yii::app()->user->userModel);
     $form->resolveValueAndSetToModel($adapter, 'date');
     $this->assertEquals(DateTimeUtil::convertTimestampToDbFormatDate(time() + 86400), $model->date);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:11,代码来源:WorkflowActionAttributeFormResolveValueTest.php

示例5: testTriggerBeforeSaveLessThanXAfterTriggeredDate

 /**
  * @depends testTriggerBeforeSaveAtLeastXBeforeTriggeredDate
  */
 public function testTriggerBeforeSaveLessThanXAfterTriggeredDate()
 {
     $workflow = self::makeOnSaveWorkflowAndTriggerForDateOrDateTime('date', 'Less Than X After Triggered Date', null, 'WorkflowsTestModule', 'WorkflowModelTestItem', null, 5, TimeDurationUtil::DURATION_TYPE_DAY);
     $model = new WorkflowModelTestItem();
     $model->lastName = 'someLastName';
     $model->string = 'something';
     //At this point the date value is null, so it should not trigger
     $this->assertFalse(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     //Set the date to some time within the last day. it should pass
     $model->date = DateTimeUtil::convertTimestampToDbFormatDate(time() - 86400);
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     $model->date = DateTimeUtil::convertTimestampToDbFormatDate(time() + 86400);
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     $model = self::saveAndReloadModel($model);
     //Even though it changed, it changed to null, so it should not fire
     $model->date = null;
     $this->assertFalse(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     $model = self::saveAndReloadModel($model);
     //This date is way in the future, so it should definitely not fire
     $model->date = '2020-07-03';
     $this->assertFalse(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     //The date is 6 days in the future, it should not fire
     $model->date = DateTimeUtil::convertTimestampToDbFormatDate(time() + 86400 * 6);
     $this->assertFalse(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     //This date is 5 days in the future, it should not fire
     $model->date = DateTimeUtil::convertTimestampToDbFormatDate(time() + 86400 * 5);
     $this->assertFalse(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:31,代码来源:WorkflowTriggersUtilForDateTest.php

示例6: __construct

 /**
  * @param SavedCalendarSubscriptions $savedCalendarSubscriptions
  * @param array $config
  */
 public function __construct(SavedCalendarSubscriptions $savedCalendarSubscriptions, array $config = array())
 {
     $this->savedCalendarSubscriptions = $savedCalendarSubscriptions;
     foreach ($config as $key => $value) {
         $this->{$key} = $value;
     }
     $this->startDate = DateTimeUtil::convertTimestampToDbFormatDate(strtotime($this->startDate));
     $this->endDate = DateTimeUtil::convertTimestampToDbFormatDate(strtotime($this->endDate));
     $this->_itemCount = 0;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:14,代码来源:CalendarItemsDataProvider.php


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