Time selector

Re: Time selector

by Davo Smith -
Number of replies: 3
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
There is a 'duration' field available (if you mean "time" as in "amount of time" rather than "time of day").

Other than that, you can either create a "group" with an hour + minute selector elements within it, or you can make a custom field type (based on the date + time selector) and use that (if you go down that route, make sure you call the MoodleQuickForm::registerElementType() function to let Moodle know about your custom field type).
Average of ratings: Useful (1)
In reply to Davo Smith

Re: Time selector

by ns smoosavi -
Hi Davo
thank you for answer
please tell me ، how to create a group
Does the moodel have a way to create a group of elements in the form?
In reply to ns smoosavi

Re: Time selector

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In reply to Davo Smith

Re: Time selector

by ns smoosavi -

Thanks a lot

good luck  Davo

my code:

for ($i = 0; $i <= 23; $i++) {
        $hours[$i] =  sprintf("%02d", $i) ;
      }
     for ($i = 0; $i < 60; $i++) {
        $minutes[$i] ="   " .  sprintf("%02d", $i);
     }
    
      $timearray=array();
      $timearray[]=& $mform->createElement('select', 'minutes', '', $minutes);
      $timearray[]=& $mform->createElement('select', 'hours', '', $hours);
      $mform->addGroup( $timearray,'timearr',' start time' ,' ',false);