Custom date formats were allowed in latest 7.x-2.10 release, now, if I goto
Content Type » Manage Display
Now, change date field formatter settings to use custom format type & give a custom format say "d-M-Y".
Click Update & save display settings for content type.

After saving, re-open formatter settings, value for custom_date_format is not getting saved.

When a content is viewed with this setting. Following 2 things happen.
1. Date field is not shown.
2. Following error messages are shown.

Notice: Undefined index: custom_date_format in date_formatter_format() (line 447 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/contrib/date/date.module).
Notice: Undefined index: formatted_timezone in theme_date_display_combination() (line 139 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/contrib/date/date.theme).
Notice: Undefined index: formatted_time in theme_date_display_combination() (line 145 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/contrib/date/date.theme).
Notice: Undefined index: formatted_time in theme_date_display_combination() (line 147 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/contrib/date/date.theme).

custom date format were added in this issue : #1504202: Allow entering of custom date format in Views field handlers

CommentFileSizeAuthor
#3 formatter_settings_for-2902829-3.patch364 bytesjaykandari

Comments

JayKandari created an issue. See original summary.

jaykandari’s picture

Assigned: Unassigned » jaykandari
jaykandari’s picture

StatusFileSize
new364 bytes

Added an entry in hook_field_formatter_info() for custom_date_format

Kindly Review, Thanks!

jaykandari’s picture

Assigned: jaykandari » Unassigned
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: formatter_settings_for-2902829-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

nileshlohar’s picture

Status: Needs work » Reviewed & tested by the community

Verified patch in #3 and it works well.

tucho’s picture

The patch at #3 worked for me too.

mr.york’s picture

Thank you patch, #3 works for me.

matthiasm11’s picture

Patch #3 works for me, D7.56 with Date 7.x-2.10. Settings are saved correctly. (and are exported to features).

damienmckenna’s picture

kmonty’s picture

Priority: Normal » Major

Marking #2882574: Notice: Undefined index: custom_date_format in date_formatter_format() as a duplicate, despite being the original issue, as it does not have a patch attached.

Escalating the priority, as this is a significant regression.

woodhous@email.unc.edu’s picture

The patch did not fix anything for me.

I'm using Date module 7.x.2.10 and started seeing this . I applied the patch referenced at #2902829: Formatter settings for Custom date type is not getting saved, however it didn't fix the problem.

Notice: Undefined index: formatted_timezone in theme_date_display_combination() (line 139 of /home/docs/public_html/sites/all/modules/date/date.theme).

It is breaking my commerce site. I have products with date fields and line items with date fields. I'm not seeing a problem with saving custom dates.

** NOTE ** I installed date-7.x-2.10+5-dev and the patch and still get the Notice.

Next, I updated commerce and still see the problem.

woodhous@email.unc.edu’s picture

The error is in the date.theme file and complaining that the array index does not exist. Here's the code below. The index 'formatted_timezone' is not valid. I only have datepicker (pop-up calendar). It would need a date format, not a timestamp format. The default date format was a timestamp and so I did change it to a date format., thinking that would fix the problem, but it didn't. Either way it gives an error. I'm guessing because the custom field is a calendar popup, and not having anything to do with timestamp.

// Pull the timezone, if any, out of the formatted result and tack it back on
// at the end, if it is in the current formatted date.
$timezone = $dates['value']['formatted_timezone']; <<<<<------ error
if ($timezone) {
$timezone = ' ' . $timezone;
}

woodhous@email.unc.edu’s picture

Update to my reported problem above: commerce product and line item dates

I played around with the Pop-up calendar settings. I changed the date format to be a timestamp format and checked the boxes for hour and minute. When I added it to the shopping cart in this format, I didn't see the errors anymore, however it showed a time along with the date for the pop-up calendar, so I unchecked the hour and minute boxes, but kept the full timestamp format. I did that for both the Product date ranges, as well as the line items for all. So I guess Pop-up calendar is really a date AND time picker and so probably always need a timestamp format. If that is the case, I'm not sure why it lets me select a custom date format, but whatever. I think it is working now. I'll need to monitor the logs to make sure.

charly71’s picture

I tried to apply patch but the notice still appears. My problem is exactly like #12 but I'm not able to change the date format to timestamp like explained here https://www.drupal.org/project/date/issues/2902829#comment-12473439 . So the issue for me is still open.

damienmckenna’s picture

@woodhous: Please open a new issue for that, it doesn't seem to be the same problem as this one.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you all.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

anrikun’s picture