Warning generated when editing a node and don't permitted save, generate error message "You have to specify a valid date."
On Drupal\node\NodeFormController
before
$node->date = format_date($node->getCreatedTime(), 'custom', 'Y-m-d H:i:s O');
after
$node->date = format_date($node->getCreatedTime(), 'custom', 'Y-m-d HH:mm:ss Z');
Example:
print_r($node->getCreatedTime());//1377543481
$node->date = format_date($node->getCreatedTime(), 'custom', 'Y-m-d H:i:s O');
print_r($node->date); //2013-58-26 15::
$node->date = format_date($node->getCreatedTime(), 'custom', 'Y-m-d HH:mm:ss Z');
print_r($node->date); //2013-58-26 15:58:01 -0300
Warning: date_format() expects parameter 1 to be DateTime, boolean given in Drupal\node\NodeFormController->form() (line 202 of core/modules/node/lib/Drupal/node/NodeFormController.php).
Comment | File | Size | Author |
---|---|---|---|
#2 | 2074535-dateformat-custom-string-2.patch | 1.53 KB | Cyberwolf |
Comments
Comment #1
Cyberwolf CreditAttribution: Cyberwolf commentedComment #2
Cyberwolf CreditAttribution: Cyberwolf commentedThis seems to occur when a 'custom' formatting string is passed to format_date() and PHPs Internationalization (intl) extension is available. Drupal's date classes try to use intl for formatting dates if it's available, but intl expect ICU style date format strings which differ from PHP date formats.
I think a proper, quick way to solve this for now is ignoring intl when a custom date format is passed to format_date(). A patch is attached that takes this approach. I replaced the variable $key as well with $format_string_type which is much better describing the contents of the variable.
Comment #3
Cyberwolf CreditAttribution: Cyberwolf commentedComment #5
Cyberwolf CreditAttribution: Cyberwolf commentedSeems like this is a duplicate of #2000384: php-intl module causes problems with Date and Time fields when editing Basic Page.
Edit: had another look at it but this is not exactly the same problem.
Comment #6
Cyberwolf CreditAttribution: Cyberwolf commentedComment #7
Cyberwolf CreditAttribution: Cyberwolf commentedComment #8
marcingy CreditAttribution: marcingy commentedclosing because of #2276183: Date intl support is broken, remove it