I am creating a custom form with "date_popup" form fields.
The only issue I have is that the default_value for the date popup form field shows only the first digit of the year, not the whole date.
Can anyone help with this?
Clive was absolutely right: The default value MUST be set using the date format "Y-m-d", such as with
The difference is that I used "Y-M-d" instead of "Y-m-d" for #default_value.
For Drupal 8:
use Drupal\Core\Datetime\DrupalDateTime; $form['mydatefield']['widget']['value']['#default_value'] = DrupalDateTime::createFromTimestamp(strtotime($mydatestring));