public static function fromString($time) { try { $date = new \DateTime($time); } catch (\Exception $e) { throw new \InvalidArgumentException(sprintf('Invalid time "%s".', $time)); } return self::fromDate($date); }
public function testFromString() { $time = Time::fromString('2pm'); $this->assertEquals(14, $time->getHours()); $this->assertEquals(0, $time->getMinutes()); }