Page 1 of 1

PHP date

Posted: Tue Dec 07, 2004 4:30 am
by dalai
Hi, im new to php, im trying to return todays date + 1 year, seems simple but i cant get it sorted.

ive tried
<?php $nextyear = mktime(date("m"), date("d"), date("Y")+1); ?>
this returns
1102423225

not right me thinks, i also want the date seperated by /

Any help would be appriciated.

Craig

Posted: Tue Dec 07, 2004 5:18 am
by []InTeR[]
Look in the php manual for the anwser.

http://www.php.net/mktime

Posted: Tue Dec 07, 2004 5:32 am
by dalai
[]InTeR[] wrote:Look in the php manual for the anwser.

http://www.php.net/mktime
Thats helpful thanx.......not
i was looking for a working example

Posted: Tue Dec 07, 2004 5:38 am
by DrHoliday
You cant do it with mktime, but the parameters are different (you forgot the time before the date). If you really just want one year ahead, why not just add 1:

echo date('d').'/'.date('m').'/'.(date('Y')+1);

Wolfgang

Posted: Tue Dec 07, 2004 5:42 am
by dalai
Thanx that was exactly what i was looking for....

Craig

Posted: Tue Dec 07, 2004 8:58 am
by novabow
...

Posted: Tue Dec 07, 2004 9:07 am
by timvw
or for real lazy people:

Code: Select all

strtotime("now +1 year");