I need to find if custom date provided by application user is less than today's date or not.
I'm trying following code:
$today = JFactory::getDate(); // 2015-06-14 16:54:50
$expected = JFactory::getDate($data['expected_date']); // 2015-06-14 00:00:00
if ($expected < $today)
{
throw new UnexpectedValueException(JText::_('COM_MYCOMPONENT_REQUEST_EXPECTED_DATE_ERROR'));
}
As you can see above, $today
returns correct date but it returns with time which causes my if loop to fail.
I usually prefer Joomla way to implement any code. It's great!