/**
  * @inheritdoc
  */
 public static function createFromFormat($format, $time, $timezone = null)
 {
     if ($timezone) {
         $dateTime = DateTime::createFromFormat($format, $time, $timezone);
     } else {
         $dateTime = DateTime::createFromFormat($format, $time);
     }
     $simpleDateTime = new SimpleDateTime("now", $timezone);
     $simpleDateTime->setTimestamp($dateTime->getTimestamp());
     return $simpleDateTime;
 }
Example #2
0
 public function testDaysinMonth()
 {
     $start = SimpleDateTime::createFromFormat("Y-m-d", "2000-01-30");
     $end = SimpleDateTime::createFromFormat("Y-m-d", "2000-02-05");
     $timeSpan = new TimeSpan($start, $end);
     $this->assertEquals(2, $timeSpan->getDaysInMonth(1));
     $this->assertEquals(4, $timeSpan->getDaysInMonth(2));
 }
 public function testGetYear()
 {
     $test = SimpleDateTime::createFromFormat("Y-m-d", "2000-01-01");
     $this->assertEquals(2000, $test->getYear());
 }