We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47562
    • 113 Posts
    The current date type is actually a datetime. I wonder if there's any possibility of allowing for three specific types: date, time, and datetime. Each has its place, and forcing folks who want just a date or just a time to use a datetime instead seems a little bit goofy, no? When you do that, you end up with a lot of people asking how to turn off one or the other on the input form...
      • 4172
      • 5,888 Posts
      A time input-type could just be a listbox-TV with input-options like:

      @EVAL return $modx->runSnippet(getTimeOptions);


      snippet getTimeOptions could look like that:

      $start = (int) $modx->getOption('start', $scriptProperties, '0');
      $end = (int) $modx->getOption('start', $scriptProperties, '24');
      $length = (int) $modx->getOption('start', $scriptProperties, '15');
      
      $hour = $start;
      $minutes = 0;
      
      $times = array();
      
      while ($hour < $end) {
      
          $timehour = $hour < 10 ? '0' . $hour : $hour;
          $timeminutes = $minutes < 10 ? '0' . $minutes : $minutes;
      
          $times[] = $timehour . ':' . $timeminutes;
              
          $minutes += $length;
          
          if ($minutes >= 60){
              $minutes = 0;
              $hour += 1;
          }
      }
      
      return implode('||',$times);
      


      a only Date-TV could be a custom-TV - input-type

      there is for example a daterange-TV with two date-fields:
      http://modx.com/extras/package/daterangetv


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!