add some number of days to current 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
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

add some number of days to current date

Post by madhu »

hi to all.........

i have small problem , please give suggestions how to implement this feature..........

problem:

am trying to add 7 days to current system date,but it is not correctly adding.

please tell where is the problem in my code.

code:

<?php

echo $today = date("Y-m-d").'<br/>';

$month = date("m"); //06

$year = date("Y"); //2006

$day = date("d"); //08

echo $day = $day + 7 .'<br/>';

echo date ("Y-m-d", mktime ($year,$month,$day));

?>
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

Yay manual!
int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )

Code: Select all

echo date ("Y-m-d", mktime (0, 0, 0, $month, $day, $year));
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: add some number of days to current date

Post by aerodromoi »

How about:

Code: Select all

<?php
echo date("Y-m-d",strtotime("+1 week"));
?>
aerodromoi
Post Reply