This is my function below:
function Active()
{
............
$num_rows = $db->doQuery('SELECT PremiumDays, PremiumStartTime FROM Premium WHERE AccountID = ?', $_SESSION['AccountID']);
if ($num_rows == -1)
{
$this->Error('ERROR');
$db->getError();
return;
}
$data = $db->doRead();
$data['Status'] = $num_rows == 0 ? '<:SHOW_PREMIUM_STATUS:>' : '<b><font size="2" color="red">Premium is active - <%Days_Remaining%> days remaining.</font></b>';
$replace = array
(
'account_status' => $data['Status'],
'days_remaining' => number_format($data['PremiumDays'])
);
$this->content = Template::Load('account-template', $replace);
}
PremiumDays
column contains numbers like 10
,15
,30
etc.
PremiumStartTime
contains a date in this format 2018-12-17 21:13:00
What I am trying to achieve is to show the actual days of premium remaining with days_remaining
. So, I believe I need to substract from PremiumDays
the days that passed since the premium started based on the second column PremiumStartTime
.
Something like that I believe, however, I am not sure how to implement it correctly in PHP. Any help is greatly appreciated. Thank you in advance!
days_remaining = PremiumDays - (NumberOfDaysSincePremiumStarted(DateToday - PremiumStartTime))