Neos\Eel\Helper\DateHelper::year PHP Метод

year() публичный Метод

Get the year of a date
public year ( DateTimeInterface $dateTime ) : integer
$dateTime DateTimeInterface
Результат integer The year of the given date
    public function year(\DateTimeInterface $dateTime)
    {
        return (int) $dateTime->format('Y');
    }

Usage Example

 /**
  * @test
  */
 public function dateAccessorsWork()
 {
     $helper = new DateHelper();
     $date = new \DateTime('2013-10-16 14:59:27');
     $this->assertSame(2013, $helper->year($date));
     $this->assertSame(10, $helper->month($date));
     $this->assertSame(16, $helper->dayOfMonth($date));
     $this->assertSame(14, $helper->hour($date));
     $this->assertSame(59, $helper->minute($date));
     $this->assertSame(27, $helper->second($date));
 }