Jump to content

Issue with PHP/CI date/time query


nydeveloper

Recommended Posts

$query = $this->db->query('SELECT * FROM coinQuote WHERE date < DATE_SUB(CURDATE(), INTERVAL 60 MINUTE)');

In the query above, my goal is to select the rows from a table named coinQuote where the value in the date column (type = timestamp) is older than 60 minutes from the current time.  This works perfectly until every night around 2:00 AM my time (EST), which I believe is midnight on my server's time, almost every row in the table is selected.  This only happens once a day (the code with the above query runs every few minutes via a cron job) - the same time every day.

 

It's obvious to me that the date change is what's causing the issue.  Unfortunately I'm having a really tough time fixing it.  Am I taking the wrong approach here, or is this approach acceptable with a little tweaking?

Link to comment
https://forums.phpfreaks.com/topic/287279-issue-with-phpci-datetime-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.