How do I add 11 months to current date in php?

software development

#1

I have tried mysql: “ADDDate(’$currdate’, INTERVAL 11 MONTHS)” and can not get that to work (I get a Parse error). Can I accomplisht this via php?

Thanks!!!

  • Fred

#2

I don’t think there is an easy PHP function that will do it, but if you look at php.net and maybe a user put a comment with a function that will help you…

A parse error is a PHP problem, so what is the line of code you are using? What Mysql or PHP errors are you getting?


#3

Thanks for the quick response! Here is what’s going on - I’m trying to insert the date of today + 11 months into mysql when a user completes a registration form. My insert statement is:
insert into billing (ppl_seq_id, bill_date, due_date, paid_date,billed)
values ($ppl_seq, ADDDate(’$currdate’, INTERVAL 11 MONTHS),null,null,‘N’);
$ppl_seq and $currdate are php variables within my program. If I take out the ADDDate() section of the insert and replace it with my $currdate variable, I don’t get any errors. When I use the ADDDate() mysql function, I get the php parse error. It doesn’t make sense to me. Any suggestions on making the mysql work? That would probably be the best way to handle it if I can get it to work.

THanks!!

  • Fred

#4

change MONTHS to MONTH.

I tested it going to myphpAdmin, and doing a

SELECT ADDDATE( “2/12/2005”, INTERVAL 11
MONTH )

when I used MONTHS I got a parse error. MONTH however works.

-Jason

MP3Mystic Your personal Streaming MP3 Server
Dreamhost Hosting


#5

Thanks Jason - you da man! I will try this as soon as I get off work :o)

  • Fred