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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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