Re: Adding Time
| From: | Yousif Masoud | Date: | Sat, 27 Mar 2010 22:08:48 +0000 |
| Subject: | Re: Adding Time | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-303542@lists.php.net to get a copy of this message | ||
On Sat, Mar 27, 2010 at 8:41 PM, Gary <gwpaul@ptd.net> wrote:
> [...]
> <?php
>
>
> $pay_date=($_SESSION['pay_date']);
>
>
> $loan_length=($_SESSION['loan_length']);
>
> $orgDate=($_SESSION['pay_date']);
> $mth=($_SESSION['loan_length']);
> function add_date($orgDate,$mth){
> $cd = strtotime($orgDate);
> $end_date = date('Y-m-d',
> mktime(0,0,0,date('m',$cd)+$mth,date('d',$cd),date('Y',$cd)));
> return $end_date;
> }
> echo $orgDate ."<br />";
> echo $end_date ."<br />";
> echo $pay_date ."<br />";
> echo $loan_length;
> ?>
Can you echo $pay_date and show us how the input date is formatted? eg.
2010-03-27
Can you also show us the output of the last four echo statements?
This works for me:
function addMonthsToDate($start,$month)
{
return strtotime("$start + $month months");
}
$test = addMonthsToDate("2010-03-26",3);
echo date('Y-m-d',$test); // gives 2010-06-26