😕
Ok, so I'm using the following function to calculate time difference in weeks..
function calc_time_diff($ts1, $ts2, $time_unit)
{
$ts1 = intval($ts1);
$ts2 = intval($ts2);
if ($ts1 && $ts2) {
$time_lapse = $ts2 - $ts1;
$seconds_in_unit = array(
'seconds' => 1,
'minutes' => 60,
'hours' => 3600,
'days' => 86400,
'weeks' => 604800,
);
if ($seconds_in_unit[$time_unit]) {
return floor($time_lapse/$seconds_in_unit[$time_unit]);
}
}
return false;
}
$ts1 is the timestamp I have stored in the database when x is added
$ts2 is the current time using time()
and $time_unit is weeks
there is another column in the database that gives the 'active' status of x using an enum('true','false')
Basically, what I need is to show how many weeks has passed until x is declared 'inactive'... so let's say I add x on 5/1/2010 and make it inactive on 6/1/2010... it says 4 weeks even if today's date is 7/1/2010..
currently, it would display 8 weeks in the above example...
but if it is made 'active' again let's say 8/1/2010 and 'inactive' again on 8/8/2010.. i need it to continue from the 4 weeks and make it 5 weeks..
THANKS! I really appreciate any help in the matter