Search code examples
phpdatephp-carbon

carbon return number of days for a given year


Can Carbon return number of days for a given year?

    $dt = Carbon::parse($year . '-'. 1 .'-' . $from);

    var_dump($dt->format('z') + 1 );

this does not seems to work


Solution

  • echo 'Days in the year: ', 365 + $dt->format('L');
    

    L: Whether it's a leap year; 1 if it is a leap year, 0 otherwise