aozde Posted February 22, 2009 Share Posted February 22, 2009 I look all around about my question but i couldn't find anythink like that. i have two dates $date="10/24/2009"; $date="11/10/2009"; i would like to calculate like this for 10. month -> 31-24=7 days for 11. month -> 30-10=20 days and if i use dates like this i want to calculate like that $date="10/24/2009"; $date="12/10/2009"; for 10. month -> 31-24=7 days for 11. month -> 30 days for 12. month -> 31-10=21 days i need this because i try to create a rental system and in this system all price change for every month. thanks a lot for any help... Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted February 22, 2009 Share Posted February 22, 2009 Uhm, you can check how many days are in a month with date, I'm not sure exactly what you want. <?php $date = explode('/', '10/24/2009'); echo date('t', mktime(0, 0, 0, $date[0], $date[1], $date[2])); Quote Link to comment Share on other sites More sharing options...
aozde Posted February 23, 2009 Author Share Posted February 23, 2009 OK. i know i haven't got enough English:) but i need that codes automatic calculate how many month and each month have how many days between dates. $date="10/24/2009"; $date="12/10/2009"; for 10. month -> 31-24=7 days for 11. month -> 30 days for 12. month -> 31-10=21 days finally $month10=7 $month11=30 $month12=21 Quote Link to comment Share on other sites More sharing options...
aozde Posted February 23, 2009 Author Share Posted February 23, 2009 i found this for $date1 = "2004-01"; $date2 = "2004-12"; $d1 = substr($date1,5,2); $d2 = substr($date2,5,2); while($d1 <= $d2){ if(strlen($d1) == 1){$d1 = "0".$d1;} echo $d1."<br>"; $d1 = $d1 + 1; } output: 01 02 03 04 05 06 07 08 09 10 11 12 when I pass the dates 2004-01 and 2004-12 but i need same time $date="10/24/2009"; $date="12/10/2009"; for 10. month -> 31-24=7 days for 11. month -> 30 days for 12. month -> 31-10=21 days $month10=7 $month11=30 $month12=21 witch month have how many days. thanks again... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.