I've got 2 fields to populate: how many times the page is called per 15 minutes and per hour.
Following fields are DateTime in MySql:
$lastAccess15m=$row['lastAccess15m'];
$lastAccessHour=$row['lastAccessHour'];
And these fields are ints:
$accessPer15m=$row['accessPer15m'];
$accessPerHour=$row['accessPerHour'];
I want to compare current time with $lastAccess15
, and if the time distance is larger than 15 minutes, set the value of $lastAccess15
to current time, and reset $accessPer15m
, otherwise, increment $accessPer15m
. The same goes for $lastAccessHour
and $accessPerHour
, after which those values have to be saved to mysql database.
How do I get the timespan between current time and $accessPer15m in minutes/hours?