I use: $today = date("F - j - Y"); however I want to add a certain number of days to it. Like: $nextweek = 7 How can I add those 7 days to the current date? and still keep it in the same format.
check the example from the manual: <?php $tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); ?> PHP:
Some functions I use with MySQL database : function dt_only_date_minus_x_days( $x ) { return date("Y-m-d", time( ) - ( $x * 24 * 60 * 60 ) ); } function dt_minus_x_days( $x ) { return date("Y-m-d G:i:s", time( ) - ( $x * 24 * 60 * 60 ) ); } function dt_now( ) { return dt_minus_x_days( 0 ); } function dt_yesterday( ) { return dt_minus_x_days( 1 ); } Code (markup): Hope It Helps.
Try this: $time = time() + (7 * 24 * 60 * 60); print $today = date("F - j - Y"); # today print $today = date("F - j - Y", $time); # next week Code (markup):
Like this? $diff= strtotime('+1 week'); $today = date("F - j - Y"); $nextweek = date("F - j - Y", $diff); PHP:
Use strtotime() Great function You can figure out a timestamp with this little guy using english like words to do it $timestamp = strtotime("1 week ago"); $timestamp = strtotime("5 hours later"); $timestamp = strtotime("18 years ago"); $timestamp = strtotime("30 days from now");