Jump to content

I need witch month have how many days, between dates


aozde

Recommended Posts

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...

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

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.