Wednesday, July 4, 2012

Re: How can I add months to a date?

This is what I have going on. 

$con_period = ceil($d['Option']['con_period']);

$ebegin_date = strtotime("+$con_period months", strtotime($d['Project']['begin_date']));

$ebgin_date = date('Y-m-d', $ebegin_date);

$d['Expense']['0']['begin_date'] = $ebegin_date;

This is what $d looks like when I hit submit. Notice the two begin dates below.

Array ( [Project] => Array ( [name] => Test 1212 [address] => 412 Dolhonde St [city] => Gretna [state_id] => 19 [zip] => 70065 [price] => 50000 [gross_sqft] => 1000 [condition_id] => 2 [location_id] => 4 [ptype_id] => 4 [begin_date] => 2012-07-04 [notes] => [user_id] => 4 )[Expense] => Array ( [0] => Array ( [name] => Antcipated Expenses [type] => 1 [cost] => 0 [begin_date] => 1362376800 ) ) )


On Wednesday, July 4, 2012 3:44:05 AM UTC-5, Mike Griffin wrote:
On Wed, Jul 4, 2012 at 6:29 AM, Steven Scaffidi <sscaff1@gmail.com> wrote:
> I want to be able to add a certain amount of months to date. Basically I
> have a from in order to start a new product. In the form, there is a begin
> date that the user select (this is a date). I want to add a variable amount
> of months to that date and then save that date into another field. How can I
> do this?
>

date("m", strtotime("+3 months"));
will give you the month number for three months in to the future.

Something like
$future = "+2 weeks";
date("Y-m-d", strtotime($future));
will give you the date two weeks in to the future.

You might be able to work something out from these.
Mike.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: