JonathanS Posted February 29, 2008 Share Posted February 29, 2008 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! Link to comment https://forums.phpfreaks.com/topic/93627-two-leap-years-in-five-year-period/ Share on other sites More sharing options...
aschk Posted February 29, 2008 Share Posted February 29, 2008 Post what you have so far and we'll guide you through what you're doing and if can do it better. Link to comment https://forums.phpfreaks.com/topic/93627-two-leap-years-in-five-year-period/#findComment-479857 Share on other sites More sharing options...
JonathanS Posted February 29, 2008 Author Share Posted February 29, 2008 date('L', mktime(12, 0, 0, 1,1,'2008')); $startYear = substr($_POST['from_yr'], -2); $endYear = substr($_POST['to_yr'], -2); $leaps = 0; for($i=$startYear; $i<=$endYear; $i++) { if(date('L', mktime(12,0,0,1,1,$i))) $leaps++; } If i input 28 february 2008 - 28 february 2013 i get 5 years 0 monts and 0 days AND 1827 days and one leap years. If i input 3 march 2008 - 3 march 2013 i get 5 years 0 monts and 0 days AND 1826 days put only one leap year. <-- Here I only want it to get one leap year. Please help. Thank you! Link to comment https://forums.phpfreaks.com/topic/93627-two-leap-years-in-five-year-period/#findComment-480469 Share on other sites More sharing options...
Barand Posted February 29, 2008 Share Posted February 29, 2008 <?php $d1 = strtotime ('2008-03-28'); $d2 = strtotime ('2013-03-28'); $days = floor (($d2-$d1) / 86400); echo $days; ?> Link to comment https://forums.phpfreaks.com/topic/93627-two-leap-years-in-five-year-period/#findComment-480507 Share on other sites More sharing options...
JonathanS Posted March 1, 2008 Author Share Posted March 1, 2008 Great! Thank you so much! Link to comment https://forums.phpfreaks.com/topic/93627-two-leap-years-in-five-year-period/#findComment-480814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.