Set Default Date on Moodle Date Picker

You can set the default date on the Moodle Date Picker using the setDefault method for example:

$mform->setDefault('date_field', date('U', strtotime("+14 days")));

The following code changes the default value of the date picker from today’s date to 14 days in the future. The second parameter returns the date in Unix format 14 days from now.