business\Time::fromDate PHP Method

fromDate() public static method

Creates a new time from a date.
public static fromDate ( DateTime $date ) : Time
$date DateTime
return Time
    public static function fromDate(\DateTime $date)
    {
        return new self($date->format('H'), $date->format('i'), $date->format('s'));
    }

Usage Example

示例#1
0
 public function testFromDate()
 {
     $time = Time::fromDate(new \DateTime('2 AM'));
     $this->assertEquals(2, $time->getHours());
     $this->assertEquals(0, $time->getMinutes());
 }