I will use the date function to get the current date but then I want to add one year to the date. So I am left with what the date would be in a years time. How would I do this?
Thanks
| SitePoint Sponsor |


I will use the date function to get the current date but then I want to add one year to the date. So I am left with what the date would be in a years time. How would I do this?
Thanks


Have you tried
PHP Code:$nextYear = (date("Y")+1);


I don't think that works. It outputs "1" for me...Originally Posted by Mittineague
This should work, though:
PHP Code:echo strtotime("+1 year");
The Banana Stand - an Arrested Development fansite
LC-3 Help - tutorials on the LC-3 educational assembly language


HUH?Originally Posted by thirteenlisk
check again, for me it evaluates to 2006
outputs:Originally Posted by thirteenlisk
1154411021
as per the php docs:
"strtotime -- Parse about any English textual datetime description into a UNIX timestamp"
So, aaron118, there you go, now you have at least 2 ways to get what you need.


Sorry, you're absolutely right. Your method works great.Originally Posted by Mittineague
The Banana Stand - an Arrested Development fansite
LC-3 Help - tutorials on the LC-3 educational assembly language


What would the code be so it gave me the day and month in a years time as well?
Thanks



$nextYear = (date("Y")+1);
echo (date("D, M,".$nextYear.""));
That would output:
Mon, Aug, 2006



My last post is kinda goofy... copying/posting with advanced setting is odd...
anyway:
if you want something like: 8/1/2006 you could do:
$nextYear = (date("Y")+1);
echo (date("m/d/".$nextYear.""));
![]()
Bookmarks