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


PHP Validation::datetime方法代码示例

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


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

示例1: checkDateTime

 /**
  * Checks datetime null or datetime
  *
  * @param object &$model use model
  * @param array $check check data array
  * @return bool
  */
 public function checkDateTime(&$model, $check)
 {
     foreach ($check as $val) {
         if (Validation::blank($val)) {
             continue;
         }
         $ret = Validation::datetime($val);
         if (!$ret) {
             return false;
         }
     }
     return true;
 }
开发者ID:NetCommons3,项目名称:Registrations,代码行数:20,代码来源:RegistrationValidateBehavior.php

示例2: beforeValidate

 /**
  * {@inheritdoc}
  */
 public function beforeValidate($options = array())
 {
     if (empty($this->data[$this->alias]['token'])) {
         $this->data[$this->alias]['token'] = $this->generate();
     }
     if (empty($this->data[$this->alias]['expires'])) {
         if (!empty($this->expires)) {
             $this->data[$this->alias]['expires'] = $this->expires;
         } else {
             $this->data[$this->alias]['expires'] = Common::read('Security.expireToken', '+3 days');
         }
     }
     if (!Validation::datetime($this->data[$this->alias]['expires'])) {
         $this->data[$this->alias]['expires'] = date('Y-m-d H:i:s', strtotime($this->data[$this->alias]['expires']));
     }
     return true;
 }
开发者ID:gourmet,项目名称:security,代码行数:20,代码来源:SecurityToken.php

示例3: checkDatetimeType

 /**
  * checkDatetimeType
  *
  * @param array $question question
  * @param string $answer answer value
  * @return array error message
  */
 public function checkDatetimeType($question, $answer)
 {
     $errors = array();
     if ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_DATE) {
         if (!Validation::date($answer, 'ymd')) {
             $errors[] = sprintf(__d('questionnaires', 'Please enter a valid date in YY-MM-DD format.'));
         }
     } elseif ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_TIME) {
         if (!Validation::time($answer)) {
             $errors[] = sprintf(__d('questionnaires', 'Please enter the time.'));
         }
     } elseif ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_DATE_TIME) {
         if (!Validation::datetime($answer, 'ymd')) {
             $errors[] = sprintf(__d('questionnaires', 'Please enter a valid date and time.'));
         }
     }
     return $errors;
 }
开发者ID:Onasusweb,项目名称:Questionnaires,代码行数:25,代码来源:QuestionnaireAnswerValidation.php

示例4: _validateDatetime

 /**
  * _validateDatetime 日付・時間の正当性
  *
  * @param object &$model use model
  * @param int $questionTypeOption 時間・日付オプション
  * @param string $answer 登録データ
  * @return bool
  */
 protected function _validateDatetime(&$model, $questionTypeOption, $answer)
 {
     if ($questionTypeOption == RegistrationsComponent::TYPE_OPTION_DATE) {
         if (!Validation::date($answer, 'ymd')) {
             $model->validationErrors['answer_value'][] = __d('registrations', 'Please enter a valid date in YY-MM-DD format.');
             return false;
         }
     } elseif ($questionTypeOption == RegistrationsComponent::TYPE_OPTION_TIME) {
         if (!Validation::time($answer)) {
             $model->validationErrors['answer_value'][] = __d('registrations', 'Please enter the time.');
             return false;
         }
     } elseif ($questionTypeOption == RegistrationsComponent::TYPE_OPTION_DATE_TIME) {
         if (!Validation::datetime($answer, 'ymd')) {
             $model->validationErrors['answer_value'][] = __d('registrations', 'Please enter a valid date and time.');
             return false;
         }
     } else {
         $model->validationErrors['answer_value'][] = __d('net_commons', 'Invalid request.');
         return false;
     }
     return true;
 }
开发者ID:NetCommons3,项目名称:Registrations,代码行数:31,代码来源:RegistrationAnswerDatetimeBehavior.php

示例5: testDatetime

 /**
  * testDatetime method
  *
  * @return void
  */
 public function testDatetime()
 {
     $this->assertTrue(Validation::datetime('27-12-2006 01:00', 'dmy'));
     $this->assertTrue(Validation::datetime('27-12-2006 01:00', array('dmy')));
     $this->assertFalse(Validation::datetime('27-12-2006 1:00', 'dmy'));
     $this->assertTrue(Validation::datetime('27.12.2006 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('27.12.2006 13:00pm', 'dmy'));
     $this->assertTrue(Validation::datetime('27/12/2006 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('27/12/2006 9:00', 'dmy'));
     $this->assertTrue(Validation::datetime('27 12 2006 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('27 12 2006 24:00', 'dmy'));
     $this->assertFalse(Validation::datetime('00-00-0000 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('00.00.0000 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('00/00/0000 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('00 00 0000 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('31-11-2006 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('31.11.2006 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('31/11/2006 1:00pm', 'dmy'));
     $this->assertFalse(Validation::datetime('31 11 2006 1:00pm', 'dmy'));
 }
开发者ID:alvaroziqar,项目名称:galei,代码行数:25,代码来源:ValidationTest.php

示例6: __checkMinMaxDateTime

 /**
  * __checkMinMaxDateTime
  * min and max is require both value
  *
  * @param object &$model use model
  * @param bool $check post data
  * @return bool
  */
 private function __checkMinMaxDateTime(&$model, $check)
 {
     if ($model->data['QuestionnaireQuestion']['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_DATE_TIME) {
         if (!Validation::datetime($model->data['QuestionnaireQuestion']['min'])) {
             return false;
         }
         if (!Validation::datetime($model->data['QuestionnaireQuestion']['max'])) {
             return false;
         }
     }
     return true;
 }
开发者ID:Onasusweb,项目名称:Questionnaires,代码行数:20,代码来源:QuestionnaireValidateBehavior.php


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