예제 #1
0
 public function testDateTime()
 {
     $datetime = DateTime::fromFormat('y-m-d', '99-01-01');
     $this->assertEquals('1999-01-01 00:00:00', (string) $datetime);
 }
예제 #2
0
파일: field.php 프로젝트: photon/photon
 public function toPhp($value)
 {
     if (in_array($value, $this->empty_values, true)) {
         return '';
     }
     if (is_object($value) && 'photon\\datetime\\DateTime' === get_class($value)) {
         return $value;
     }
     foreach (explode('||', $this->input_formats) as $format) {
         $date = \photon\datetime\DateTime::fromFormat($format, $value);
         if (false !== $date) {
             return $date;
         }
     }
     throw new Invalid($this->error_messages['invalid']);
 }