very basic date + math question
Posted: Mon Jan 28, 2008 6:09 pm
I'm trying to generate a string (I'm calling it $checksetcutoffdate) which represents the date three days ago in this format: YYYYMMDD.
I've got the query to get today's date in this format working but I seem to be doing something wrong in the subtraction of three days.
Seems like it should be easy, so help is appreciated!
I've got the query to get today's date in this format working but I seem to be doing something wrong in the subtraction of three days.
Seems like it should be easy, so help is appreciated!
Code: Select all
//get current date
$currentdate = mysql_query("SELECT CURDATE() + 0");
$checkcurrentdate = mysql_fetch_object($currentdate);
//set cutoff date
$setcutoffdate = '$checkcurrentdate' - 3;
$checksetcutoffdate = mysql_fetch_object($setcutoffdate);
echo '<pre>'.print_r($checksetcutoffdate).'</pre>';