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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.