Re: [PHP] Adding Time

2010-03-31 Thread Anshul Agrawal
On Sun, Mar 28, 2010 at 4:22 AM, Gary  wrote:

> Perfect, thank you very much for your help!
>
> Gary
>
>
> "Yousif Masoud"  wrote in message
> news:x2tbffe24ad1003271548l65cb6e65qd8f35ae0636e...@mail.gmail.com...
> > On Sat, Mar 27, 2010 at 10:26 PM, Gary  wrote:
> >
> >> [...]
> >>
> >
> > $end_date=date('m-d-Y',strtotime('$mth')) + date('m-d-Y',
> >> strtotime('$pay_date'));
> >>
> >> [...]
> >
> >
> > Try changing above to:
> >
> > $end_date = date('m-d-Y',strtotime("$pay_date + $mth months"));
> >
> > I think your mail client took it out of the add_date function.
> >
> >
> >
> > __ 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
>
>
Be cautious while using this.

$mth = 1;
$pay_date = "2010-01-31";
$end_date = date('m-d-Y',strtotime("$pay_date + $mth months"));
echo $end_date; //03-03-2010, will take you to March

Thanks,
Anshul


Re: [PHP] Adding Time

2010-03-27 Thread Gary
Perfect, thank you very much for your help!

Gary


"Yousif Masoud"  wrote in message 
news:x2tbffe24ad1003271548l65cb6e65qd8f35ae0636e...@mail.gmail.com...
> On Sat, Mar 27, 2010 at 10:26 PM, Gary  wrote:
>
>> [...]
>>
>
> $end_date=date('m-d-Y',strtotime('$mth')) + date('m-d-Y',
>> strtotime('$pay_date'));
>>
>> [...]
>
>
> Try changing above to:
>
> $end_date = date('m-d-Y',strtotime("$pay_date + $mth months"));
>
> I think your mail client took it out of the add_date function.
>
>
>
> __ 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



Re: [PHP] Adding Time

2010-03-27 Thread Yousif Masoud
On Sat, Mar 27, 2010 at 10:26 PM, Gary  wrote:

> [...]
>

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


Try changing above to:

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

I think your mail client took it out of the add_date function.


Re: [PHP] Adding Time

2010-03-27 Thread Yousif Masoud
On Sat, Mar 27, 2010 at 10:26 PM, Gary  wrote:

> [...]
>
> strtotime('$pay_date'));
>
> [...]
>

If you want the value of $pay_date to be the argument of strtotime, you need
to enclose it in double quotes (do the same for all other occurrences).

Try:

strtotime("$pay_date");

[...]

When a string  is
specified in double quotes or with heredoc,
variablesare
parsed within it.

[...]

from: http://php.net/manual/en/language.types.string.php
Beginning of Variable Parsing Section


Re: [PHP] Adding Time

2010-03-27 Thread Gary
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 ."";
echo $mth ."";
echo 2 ."";
echo $end_date ."";
echo 3 ."";
echo $pay_date ."";
echo 4 ."";
echo $loan_length."";
echo 5 ."";
echo $orgDate."";



?>
***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"  wrote in message 
news:x2sbffe24ad1003271508xb1f414fck7b6eb93a6cd79...@mail.gmail.com...
> On Sat, Mar 27, 2010 at 8:41 PM, Gary  wrote:
>
>> [...]
>>>
>>
>>  $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 ."";
>> echo $end_date ."";
>> echo $pay_date ."";
>> 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



Re: [PHP] Adding Time

2010-03-27 Thread Yousif Masoud
On Sat, Mar 27, 2010 at 8:41 PM, Gary  wrote:

> [...]
>
>
>  $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 ."";
> echo $end_date ."";
> echo $pay_date ."";
> 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


Re: [PHP] Adding Time

2010-03-27 Thread Gary
It is a multi page form with all information being writting to the database 
via the $_SESSION's.

Gary


"Yousif Masoud"  wrote in message 
news:k2qbffe24ad1003271414za1377a2dsb0e4a2d23d411...@mail.gmail.com...
> On Sat, Mar 27, 2010 at 8:41 PM, Gary  wrote:
>
>> [...]
>>>
>>
>>  $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 ."";
>> echo $end_date ."";
>> echo $pay_date ."";
>> echo $loan_length;
>> ?>
>
>
> You access form element values via the $_POST superglobal, why are you 
> using
> $_SESSION?
>
> http://php.net/manual/en/reserved.variables.post.php
>
>
>
> __ 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



Re: [PHP] Adding Time

2010-03-27 Thread Yousif Masoud
On Sat, Mar 27, 2010 at 8:41 PM, Gary  wrote:

> [...]
>
>
>  $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 ."";
> echo $end_date ."";
> echo $pay_date ."";
> echo $loan_length;
> ?>


You access form element values via the $_POST superglobal, why are you using
$_SESSION?

http://php.net/manual/en/reserved.variables.post.php


Re: [PHP] Adding Time

2010-03-27 Thread Gary
Thanks for your reply.  This comes from the manual, I have tried to change 
to my variables. I am not getting any error messages, but I am not able to 
add the $loan_length to the $pay_date.

Thanks again for any help.

gary

";
echo $end_date ."";
echo $pay_date ."";
echo $loan_length;
?>

"Nilesh Govindarajan"  wrote in message 
news:4bae4578.9080...@itech7.com...
> On 03/27/2010 11:13 PM, Gary wrote:
>> I have a manual input field to add a date on a form.  There is another
>> manual input field to add number of months (This is for a loan
>> agreement).I am trying to add the two together to get an ending date. I
>> dont think I am close, can anyone poimt me in the right direction.
>>
>>
>> $pay_date=($_SESSION['pay_date']);
>> $loan_length=($_SESSION['loan_length']);
>>
>>
>> $pay_date = new DateTime($_SESSION['pay_date']);
>>
>> $end_date = new DateTime($_SESSION['pay_date']) +
>> ($_SESSION['loan_length']);
>>
>> echo $end_date->format("m-d.Y").'';
>>
>>
>> date_add($pay_date + new DateInterval($_SESSION['loan_length']));
>> echo ''.$date->format("d-m-Y");
>>
>> Gary
>>
>> __ Information from ESET NOD32 Antivirus, version of virus
>> signature database 4978 (20100326) __
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>>
>
> Add time in Unix Timestamps. Then format it using strftime.
>
> Also to format inputted date time in the form, check in php manual, to 
> convert dates to timestamps (i forgot the func. name).
>
> -- 
> Nilesh Govindarajan
> Site & Server Administrator
> www.itech7.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
>
>
> 



__ 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



Re: [PHP] Adding Time

2010-03-27 Thread Nilesh Govindarajan

On 03/27/2010 11:13 PM, Gary wrote:

I have a manual input field to add a date on a form.  There is another
manual input field to add number of months (This is for a loan
agreement).I am trying to add the two together to get an ending date. I
dont think I am close, can anyone poimt me in the right direction.


$pay_date=($_SESSION['pay_date']);
$loan_length=($_SESSION['loan_length']);


$pay_date = new DateTime($_SESSION['pay_date']);

$end_date = new DateTime($_SESSION['pay_date']) +
($_SESSION['loan_length']);

echo $end_date->format("m-d.Y").'';


date_add($pay_date + new DateInterval($_SESSION['loan_length']));
echo ''.$date->format("d-m-Y");

Gary

__ Information from ESET NOD32 Antivirus, version of virus
signature database 4978 (20100326) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com






Add time in Unix Timestamps. Then format it using strftime.

Also to format inputted date time in the form, check in php manual, to 
convert dates to timestamps (i forgot the func. name).


--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत महान !
मम भारत: महत्तम भवतु !

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



[PHP] Adding Time

2010-03-27 Thread Gary
I have a manual input field to add a date on a form.  There is another 
manual input field to add number of months (This is for a loan agreement).I 
am trying to add the two together to get an ending date. I dont think I am 
close, can anyone poimt me in the right direction.



 $pay_date=($_SESSION['pay_date']);
$loan_length=($_SESSION['loan_length']);


$pay_date = new DateTime($_SESSION['pay_date']);

$end_date = new DateTime($_SESSION['pay_date']) + 
($_SESSION['loan_length']);


echo $end_date->format("m-d.Y").'';


date_add($pay_date + new DateInterval($_SESSION['loan_length']));
echo ''.$date->format("d-m-Y");

Gary 



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 4978 (20100326) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com




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