PDA

View Full Version : date() function ...


HormonX
11-01-2002, 04:38 PM
Hello again,

Question i have is this. I have users fillout a form where they input all kind of info. But what i need to do is to purge some of the entries in the database every 14 days. What do you guys sugest.

I was thinking of using date() to enter the date that the form was filled out and then use datenow() to compare the two.

Does that sound like something that can be done ?

Please let me know or give some sugestions.

thanx

HormonX

IndyTim
11-02-2002, 12:27 AM
A technique I use extensively in my tables is to convert the date to an integer and then do the computations based on the integer value of the date. For convenience sake, I've put this into a callable function. Attached script for the function:

function GetDate2($MySQLDate)
{
$date_array=explode("-",$MySQLDate);
$var_type="integer";
$var_year=$date_array[0];
$var_month=$date_array[1];
$var_day=$date_array[2];

$var_timestamp=mktime(0,0,0,$var_month,$var_day,$var_year);
$var_timestamp=$var_timestamp/86400;
settype($var_timestamp,$var_type);
return($var_timestamp);
}

Hope this apprach helps.

IndyTim