Ouzo\Utilities\Clock::fromTimestamp PHP 메소드

fromTimestamp() 공개 정적인 메소드

Obtains a Clock set to to a specific point using Unix timestamp.
public static fromTimestamp ( $timestamp ) : Clock
$timestamp
리턴 Clock
    public static function fromTimestamp($timestamp)
    {
        $dateTime = new DateTime();
        $dateTime->setTimestamp($timestamp);
        return new Clock($dateTime);
    }

Usage Example

예제 #1
0
 /**
  * @test
  */
 public function shouldCreateClockForGivenTimestamp()
 {
     //given
     $clock = Clock::fromTimestamp(1427207001)->setTimezone('UTC');
     //when
     $result = $clock->format();
     //then
     $this->assertEquals('2015-03-24 14:23:21', $result);
 }