Geting information from a Moodle form

Geting information from a Moodle form

από Jose Velazquez-Torres -
Αριθμός απαντήσεων: 1

Hello!!

Im creating a custom form to reschedule an activity under specific paramaters. I already created the form but Im having issues reading the information gather in the form, specialy the date, for that Im using the date_time_selector element. 

if ($mform->is_cancelled()) {

        //Handle form cancel operation, if cancel button is present on form

        redirect(new moodle_url($CFG->wwwroot . '/course/view.php?id=' . 2));

    } else if ($fromform = $mform->get_data()) {

        //In this case you process validated data. $mform->get_data() returns data posted in form.

        $activityname = $fromform->mytime;

        echo 'this ' . $activityname . ' ';

    }

Here Im trying to display the value and I get numeric code and not the actual date and time values. I need this values to update the parameters in the data base table. Could someone point me in the right direction or tell me what Im missing to achive this?

Μέσος όρος βαθμολογίας: -
Σε απάντηση σε Jose Velazquez-Torres

Re: Geting information from a Moodle form

από Mark Sharp -
Φωτογραφία Core developers Φωτογραφία Particularly helpful Moodlers Φωτογραφία Plugin developers
That's a unixtime stamp that you can convert using PHP's date function: https://www.php.net/manual/en/function.date.php
Just give it the format of the output and the timestamp e.g. `$readabledate = date('r', $fromform->mytime);` (see https://www.php.net/manual/en/datetime.format.php for format codes)