Given that the date stored is UTC = 0 then how do I get all records with the date of today?

SELECT * FROM table Where datefield = CURDATE()

won't work because the stored value is the day before.

So another way of asking this is - how do I add the timezone offset to the datefield field to retrieve records that match that day?


  • 1
    You can't get correct results since your field type is DATE. To take timezone into account for today, this should be DATETIME. Then you can correctly compare with timezone.
    – Rene Korss
    Commented Apr 28, 2015 at 8:35

1 Answer 1


You can do this by using JDate to build your query.

$date = new JDate(); //this returns NOW in UTC
// We use JDate::format instead of toSQL because we aren't using a datetime data type
    ->where('datefield = '.$db->quote($date->format('Y-m-d')));

I hope this helps =^D Happy Joomla!ng

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.