get future 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
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

get future date

Post by nite4000 »

Hey I know this is simple to a lot and it is to me however seems like nothing I have tried works

When I am doing is getting the current date and time and inserting it into a field which I have got to work

However I need to go up by 1 day for the date but leaving the time the same

Here is what I have

Code: Select all



$newdate = mysql_result($checksurfed, 0, "date");


$newtime = mysql_result($checksurfed, 0, "time");
 

[b]$date1 = (date($newdate, strtotime($newdate)) . " +1 day");[/b]


$do_stats = mysql_query("UPDATE table SET field1='$date1 $newtime'") or die (mysql_error());


The code in bold is what I am trying to work with but its not going up by 1 day and then saving

Any help would be great
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: get future date

Post by AbraCadaver »

I'm not sure what format your date needs to be in, but you need to read the docs for the two functions. Here's an example:

Code: Select all

$date1 = date('Y-m-d', strtotime('+1 day', $newdate));
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply