Re: Adding Time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have copied the echo and the code, for clarity I have echo'd 1,2,3,   etc 
to see which is working.

Thank you for your help. Hope this is clear.

Gary

$loan_length=($_SESSION['loan_length']); //is set to 36 months
$pay_date=($_SESSION['pay_date']); //is set to 01-05-2010
$orgDate=($_SESSION['pay_date']);
$mth=($_SESSION['loan_length']);

$end_date=date('m-d-Y',strtotime('$mth')) + date('m-d-Y', 
strtotime('$pay_date'));

$loan_length=date('m-d-Y');
$mthdate=date('m-d-Y',
function add_date($orgDate,$mth){
  $cd = strtotime($orgDate);

  return $end_date;
}
$orgDate=date("m",strtotime('$loan_length'));
echo 1 ."<br />";
echo $mth ."<br />";
echo 2 ."<br />";
echo $end_date ."<br />";
echo 3 ."<br />";
echo $pay_date ."<br />";
echo 4 ."<br />";
echo $loan_length."<br />";
echo 5 ."<br />";
echo $orgDate."<br />";



?>
***Page output***

1
36 //this is correct
2
24 //this is not
3
01-05-2010
4
03-27-2010
5
12 //this is not


"Yousif Masoud" <yousif.masoud@xxxxxxxxx> wrote in message 
news:x2sbffe24ad1003271508xb1f414fck7b6eb93a6cd79c8f@xxxxxxxxxxxxxxxxx
> On Sat, Mar 27, 2010 at 8:41 PM, Gary <gwpaul@xxxxxxx> 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
>
>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4978 (20100326) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
> 



__________ Information from ESET Smart Security, version of virus signature database 4978 (20100326) __________

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux