Posted By

bartclaeys on 04/22/09


Tagged

year days


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fackz


number of days in a certain year


 / Published in: PHP
 

  1. function daysinyear($year)
  2. {
  3. $endyear = mktime(24, 0, 0, 12, 31, $year);
  4. $beginyear = mktime(0, 0, 0, 1, 1, $year);
  5. $diff = $endyear - $beginyear;
  6. $days = $diff / (60*60*24);
  7. return $days;
  8. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: mrhoo on April 22, 2009

That is a very labor intensive way to calculate the days in a year, given the year.

function daysinyear($year){ if($year%4==0 && ($year%400==0 || $year%100)) return 366; return 365; }

You need to login to post a comment.