2

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?

Mat

  • 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 Apr 28 '15 at 8:35
2

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
$query->select('*')->from('table')
    ->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, privacy policy and cookie policy

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