Updated: Comment #N

Problem/Motivation

To reproduce:
- Do a clean Drupal 8 install with Standard install profile.
- Go to Add Content (node/add)
- Choose Basic Page (end up on node/add/page)
- Type a title and body.
- Attempt to save. You will get an error message because the Authoring Information has an invalid date in it. See screenshot for what I am seeing. It looks like someone put YYYY-MM-DD in code as a date format somewhere, and then ran it through PHP's standard date formatting, so it turned Y into a two-digit year (repeated 4 times), etc. and the date in my field is: 13131313-JulJul-3131 time: 13:0707:1111 [the actual date was July 31, 2013, at 13:07:11].
Screen shot of authoring area of Node Add form with invalid date in it
- The error message is also totally bogus:

The Authored on date is invalid. Please enter a date in the format 13131313-JulJul-3131 13:0707:2525.

Proposed resolution

Fix the date format code for node authored date.

Remaining tasks

Find the problem and fix it.

User interface changes

The UI will work when creating a new node.

API changes

None.

None.

CommentFileSizeAuthor
#6 authored_on_error.JPG99.22 KBMicha1111
invaliddate.png15.77 KBjhodgdon

Comments

jhodgdon’s picture

Component: node.module » datetime.module

Actually, based on the help text below the Authored field, this is coming from the datetime module's form alter, not the base node module form, so moving there.

jhodgdon’s picture

I did a little debugging in datetime_form_node_form_alter().

  $format_type = datetime_default_format_type();

  // Alter the 'Authored on' date to use datetime.
  $form['author']['date']['#type'] = 'datetime';
  $date_format = entity_load('date_format', 'html_date')->getPattern($format_type);
  $time_format = entity_load('date_format', 'html_time')->getPattern($format_type);

When I printed out $format_type, $date_format, and $time_format, I ended up with:

Format type is intl and formats are yyyy-MM-dd and H:mm:ss

Those are not good PHP date formats, and are certainly the cause of this problem.... Where are they coming from?

jhodgdon’s picture

OK, these are coming from core/modules/system/config/system.date_format.html_date.yml:

id: html_date
uuid: f4028e7f-3ed8-4737-8f27-39b618214a1f
label: 'HTML Date'
status: '1'
langcode: en
locked: '1'
locales: {  }
pattern:
  php: Y-m-d
  intl: yyyy-MM-dd

So either that type of format shouldn't be in there, or the DateTime module is misusing it as a PHP date format somewhere. I'll now leave this for the maintainers of system.module and/or datetime.module to figure out what is going on.

jhodgdon’s picture

Title: Add Content results in invalid creation date » datetime.module is misusing a date format as a PHP date format on node add screen
jhodgdon’s picture

As a note, I have the 'intl' PHP module installed on this machine. timplunkett says that is what the issue is about and it's probably a duplicate of
#2000384: php-intl module causes problems with Date and Time fields when editing Basic Page

Micha1111’s picture

StatusFileSize
new99.22 KB

Still the same error with latest dev

attached screenshot

berdir’s picture

Status: Active » Closed (duplicate)

Yes, this is a duplicate of #2000384: php-intl module causes problems with Date and Time fields when editing Basic Page, which happens with specific php-intl versions. Please report your exact php and intl versions there.