Page 1 of 1

adding days to date for new date with correct month stamp

Posted: Fri Jan 07, 2011 4:26 pm
by chrismicro
I currently have this working to post the correct format:


the hour format is 00 -23

the day format is 0-31

month format is from 01-12

code:

$aud1hour = "09";
$aud1day = "20";
$aud1month = "10";

$stamp = mktime($aud1hour,0,0,$aud1month,$aud1day,0);
$formatted_date = date('g:ia, M jS',$stamp);

echo "<font face='geneva, arial, sans serif' size='2' color='#00FF00'>".$formatted_date."</font>";

//THIS WILL PRINT THE CORRECT FORMAT OF

9:00am, Oct 20th


**now here is what I need done, I need to figure out a way that if I add 12 days to $aud1day making it the number 32 What function / code can I use to convert the month to 11 and set the day to 1, or if the month is a 30 day month, or 28 or 29 ( leap year ) instead of using an insane amount of if statements.

Re: adding days to date for new date with correct month stam

Posted: Fri Jan 07, 2011 4:49 pm
by chrismicro
this worked:

$aud1hour = "13";
$aud1day = "23";
$aud1month = "12";
$add = "12";

$stamp = mktime($aud1hour,0,0,$aud1month,$aud1day,0);
$formatted_date = date('g:ia, M jS',$stamp);
$end_date = date("g:ia, M jS",strtotime("+".$add." days",$stamp));


echo "date:&nbsp;".$formatted_date."<br><br>";
echo "New Date with&nbsp;".$add." days added:&nbsp;".$end_date;