Wednesday, July 4, 2012

Re: How can I add months to a date?

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: