1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

Time element

May 27, 2013
Time element
  • Time element is useful if you need just a time value (as time of day or duration). This is derived from birthday element. While birthday uses database field type DATE instead DATETIME, time element uses TIME field type. The two together are useful when using Fabrik for manipulating data of such event management components as EventList where date and time fields are separate fields and empty fields should have NULL value.

    Time data is submitted with dropdowns, by default they are three - hours, minutes and seconds.

    Admin form allows you choose time formatting - all 3 parts, hours and minutes or minutes and seconds. Additionally you can choose which separator should be between hours, minutes and seconds (it's : by default)

    [​IMG]


    PHP Validation Example (top)


    Check if 'endtime' element is set to be 2 hours after 'starttime' element:


    PHP:

    $app = JFactory::getApplication();
    $input = $app->input;
    $startTime = $input->get('multipage___starttime_raw', array(), 'array');
    $endTime = $input->get('multipage___endtime_raw', array(), 'array');
    $startSeconds = ($startTime[0] * 60 * 60) + ($startTime[1] * 60) + $startTime[2];
    $endSeconds = ($endTime[0] * 60 * 60) + ($endTime[1] * 60) + $endTime[2];
     
    if ($endSeconds - (2 * 60 * 60) < $startSeconds)
    {
      return false;
    }
    else
    {
      return true;
    }
     
nasreddine likes this.