Date format error

Created on 2 January 2020, over 5 years ago
Updated 17 November 2024, 5 months ago

Hello,

I've some problems when I submit a form. The systems throws the following error:

Exception: DateTime object not set. a Drupal\Component\Datetime\DateTimePlus->__call() (line 355 of ...core/lib/Drupal/Component/Datetime/DateTimePlus.php).

I think the problem is related with the date format, because if I select a reversible month/day date, like 01/02/2020 (it can be read as January 2nd, or February 1st), the node is saved. However, if I select a non-reversible date (25/01/2020), the system throws the mentioned above error.


Using mm/dd/yyyy woks properly... it needs to be reviewed

Thanks,
Dani

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇪🇸Spain dromansab

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇲🇩Moldova nick.murza Moldova

    i have this issue:
    Error: Call to a member function format() on bool in Drupal\bootstrap_datepicker\Plugin\Field\FieldWidget\BootstrapDatepickerBase->massageFormValues() (line 640 of modules/contrib/bootstrap_datepicker/src/Plugin/Field/FieldWidget/BootstrapDatepickerBase.php).

    and the solution is here, i think:

    $converted_item_value = date_create_from_format($date_format, $item['value']) ? date_create_from_format($date_format, $item['value'])->format('d-m-Y') : $item['value'];
    
Production build 0.71.5 2024