src/Date.php
public static function firstWeekOfYear(int $y) : \Datetime
    {
        $date = (string)$y . "-01-01 00:00:00";
        $format = "Y-m-d H:i:s";
        $o = \DateTime::createFromFormat($format, $date);

        $wnDay = date("N", strtotime($date));
        $addD = (integer)((11 - $wnDay) % 7);

        $o->add(new \DateInterval("P" . $addD . "D"));
        $o->sub(new \DateInterval("P3D"));

        return $o;
    }
public static function firstWeekOfYear(int $y) : \Datetime
    {
        $date = (string)$y . "-01-01 00:00:00";
        $format = "Y-m-d H:i:s";
        $o = \DateTime::createFromFormat($format, $date);

        $wnDay = date("N", strtotime($date));
        $addD = (integer)((11 - $wnDay) % 7);

        $o->add(new \DateInterval("P" . $addD . "D"));
        $o->sub(new \DateInterval("P3D"));

        return $o;
    }
public static function firstWeekOfYear ( int $ y ) : \ Datetime { $ date = ( string ) $ y . "-01-01 00:00:00" ; $ format = "Y-m-d H:i:s" ; $ o = \ DateTime :: createFromFormat ( $ format , $ date ) ; $ wnDay = date ( "N" , strtotime ( $ date ) ) ; $ addD = ( integer ) ( ( 11 - $ wnDay ) % 7 ) ; $ o -> add ( new \ DateInterval ( "P" . $ addD . "D" ) ) ; $ o -> sub ( new \ DateInterval ( "P3D" ) ) ; return $ o ; }
Retorna um objeto DateTime referente ao primeiro dia da primeira semana do ano informado.

@param       int $y
Ano.

@return      DateTime
Retorna um objeto DateTime referente ao primeiro dia da primeira semana do ano informado .