Hope someone can help me. User defines two dates(dd/mm/yy, then want to display 1) Difference in days between the two inputs in dd/mm/yy and 2) the difference in days between the dates. The problem is I always want to show the difference i dd/mm/yy no matter how long the period is but the maximun value I want to show for days is 1825 or 1826(which is five years depending on if it´s one or two leapyears in the given period). Please help. Give me some hlep how to do the second bit. How do I know to stop on 1825 or 1826. Thank you so much!
The date function has the "L" syntax that returns zero or one depending on whether it's a leapyear. You can do the default 365*5 then add up the values returned from date("L") for each of the years involved. $start_year = 2000; $end_year = 2005; $days = (365 * 5); for($year = $start_year; $year <= $end_year; $year++) { $days += date('L', strtotime("1 January $year")); } Code (markup):