2

Using standard Joomla database functions, what's the right way to select new / modified items from a table? I don't want to use created > DATE_SUB(NOW(), INTERVAL 1 DAY) OR modified > DATE_SUB(NOW(), INTERVAL 1 DAY) since I'm not sure that all the new DB types supported by Joomla will accept the now() / DATESUB syntax.

6
  • How could they be greater than now()? When would they have been modified/created? Wouldn't you want to just order by created or modified and grab the first X number of that list? Feb 2, 2015 at 19:08
  • New is relative. Define what new means to you. Feb 2, 2015 at 20:52
  • @DavidFritsch-- you're right, I wasn't careful about my query, was more concerned with the theory behind it. Thanks
    – user101289
    Feb 2, 2015 at 21:26
  • 1
    Try this: created > JFactory::getDate('now -1 day')
    – Farahmand
    Feb 3, 2015 at 8:06
  • @Farahmand, I've reopened this. I'd post that as an answer. Feb 3, 2015 at 17:33

1 Answer 1

1

You can compare them with JFactory::getDate('now -1 day') like this:

created > JFactory::getDate('now -1 day')

and this:

modified > JFactory::getDate('now -1 day')

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.