date minus 3 months

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

date minus 3 months

Post by mad_phpq »

Hi,

I'd like to be able to minus 3 months from a date and then round it down to 1st of that month.

Example:

(format british time d/m/y)
today = "14/1/2009";

three months ago = "1/10/2008"

Can anyone tell me how I can do this using php?

Thanks

--Mark
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: date minus 3 months

Post by jaoudestudios »

Check out example 3 on...
http://uk3.php.net/date
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: date minus 3 months

Post by pickle »

strtotime() I think is better suited for adding or removing time.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

Re: date minus 3 months

Post by mad_phpq »

thanks jaoudestudios , that did it.
Post Reply