September 4th, 2000, 12:58 AM
I having troubles adding numbers to an existing date that is pulled from a database.
Here's the setup:
A date is stored in the database, (YYYY-MM-DD). The next record must be assigned the next days date, based on whatever the date of the previous record was.
I'm using the following code based on other date adding posts I found here at DevShed:
$sql = "SELECT * FROM Quotes";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$lastdate = $myrow["QuoteDate"];
$tomorrow = mktime(0,0,0,date("m",$lastdate) ,date("d",$lastdate)+1,date("Y",$lastdate));
$nextday = date("Y-m-d",$tomorrow);
$lastdate is the date of the last record in the DB, and $nextday is supposed to hold $lastdate + 1 - but its failing and giving me the 1970-01-01 issue.
I hope all that read this understand what I'm trying to accomplish - any help is much appreciated. Thanks
September 4th, 2000, 09:59 AM
Moog, I think that in order to obtain a valid timestamp (I mean, ready to be inserted in the database) with "date" function you have to give "YmdHis" parameter.