On my site I need to request a date/time every page reload.
The reason why is because I need to perform a database action if an hour or more has passed since the last time it was done.
Something like this (pseudo code)
select time from database table
if (time < hour_ago) {
do this + set time = now
}
My question is, is this the best way to do this? Would it be quicker if the time was stored in a txt file instead? Or another way?
I’m already using a database connection each page but just wondering if it’s worth a query just to get one date.
Databases are a good way to store persistent information. If you are already using a DB then I would see no reason to put this anywhere else.