PHP date

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
dalai
Forum Newbie
Posts: 4
Joined: Tue Dec 07, 2004 4:24 am
Location: uk

PHP date

Post 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
Last edited by dalai on Tue Dec 07, 2004 5:31 am, edited 1 time in total.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Look in the php manual for the anwser.

http://www.php.net/mktime
dalai
Forum Newbie
Posts: 4
Joined: Tue Dec 07, 2004 4:24 am
Location: uk

Post 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
DrHoliday
Forum Newbie
Posts: 11
Joined: Mon Dec 06, 2004 5:12 pm
Location: Germany

Post 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
dalai
Forum Newbie
Posts: 4
Joined: Tue Dec 07, 2004 4:24 am
Location: uk

Post by dalai »

Thanx that was exactly what i was looking for....

Craig
novabow
Forum Newbie
Posts: 1
Joined: Mon Dec 06, 2004 8:29 pm

Post by novabow »

...
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

or for real lazy people:

Code: Select all

strtotime("now +1 year");
Post Reply