websitesvalues
websitesvalues

Reputation: 137

Get time from database and compare

I want to get time from database then use it to compare with current time. How can i do it?

$timeStart = $row['timeStart'];
echo 'Time Start : '.$timeStart;
echo "</br>";
$time_offset =ICT; // Change this to your time zone
$time_a = ($time_offset * 120);
$time = date("M-d-Y H:i:s",time() + $time_a);
echo 'Current time is : '.$time;
echo "</br>";
if ($timeStart + $timeForEachDownload > $time) $totalDownload = $totalDownload + 1;

Upvotes: 0

Views: 1713

Answers (1)

Jose Vega
Jose Vega

Reputation: 10258

Change this:

if ($timeStart + $timeForEachDownload > $time)
     $totalDownload = $totalDownload + 1;

To this:

if ((strtotime($timeStart) + strtotime($timeForEachDownload)) > $time)
     $totalDownload = $totalDownload + 1;

Upvotes: 1

Related Questions