When selecting the default "Short" as the Formatter and a custom made date format as the Format, the default formatter ("Short") is eventually being used instead of the custom date format ("Date only" - see attached screenshot) (as designated in format).

When I select my custom made date as the Formatter ànd as the Format, it's printing one long string of different date formats: PMvr, 17 Dec 2010 16:15 +0100vr, 17 Dec 2010 16:15 +0100pm10 vr, 17 Dec 2010 16:15 +0100vr, 17 Dec 2010 16:15 +0100.

It's also experiencing trouble displaying the preview in Views itself.

  • Is this bug already reported / fixed?
  • What is the actual difference between the date formatter and the date format?
CommentFileSizeAuthor
Custom date format not showing in Views21.91 KBknalstaaf

Comments

knalstaaf’s picture

Title: Custom date format not working in Views3 » Custom date format not working
Project: Date » Views (for Drupal 7)
Version: 7.x-1.0-alpha2 » 7.x-3.x-dev
Component: Code » node data
Issue tags: -date

This has been reported in the issues of Date as well (unreplied since feb. 12th 2011): Problem using custom date type in view.

I'm not sure whether this is a Views or a Date issue...

knalstaaf’s picture

Issue tags: +date

I'm also getting this alert on top of the Views UI:

  • Notice: Undefined index: additional fields in date_field_views_data_alter() (line 252 of /var/www/vhosts/domain.be/httpdocs/sites/all/modules/date/date_views/date_views.module).
  • Warning: array_merge() [function.array-merge]: Argument #1 is not an array in date_field_views_data_alter() (line 252 of /var/www/vhosts/domain.be/httpdocs/sites/all/modules/date/date_views/date_views.module).
  • Notice: Undefined index: additional fields in date_field_views_data_alter() (line 252 of /var/www/vhosts/domain.be/httpdocs/sites/all/modules/date/date_views/date_views.module).
  • Warning: array_merge() [function.array-merge]: Argument #1 is not an array in date_field_views_data_alter() (line 252 of /var/www/vhosts/domain.be/httpdocs/sites/all/modules/date/date_views/date_views.module).
dawehner’s picture

This seems to be a date module problem. The date module function date_field_views_data_alter seems to be wrong.

knalstaaf’s picture

Project: Views (for Drupal 7) » Date
Version: 7.x-3.x-dev » 7.x-1.0-alpha2
Component: node data » Code
knalstaaf’s picture

Title: Custom date format not working » Custom date format not working in Views3
valderama’s picture

subscribing

steinmb’s picture

Hi.
I think also we are seeing this bug using Views 3 beta3 and PHP 5.2.6. Did some tests, and I think that it is not only custom date formats in the view that are triggering this problem, but also localized date, then changing from custom to short format still throw these errors.

Notice: Undefined index: additional fields in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Notice: Undefined index: additional fields in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Notice: Undefined variable: entity_info in field_views_field_default_views_data() (line 177 av  /drupal/sites/all/modules/views/modules/field.views.inc).
Notice: Undefined variable: entity_info in field_views_field_default_views_data() (line 178 av  /drupal/sites/all/modules/views/modules/field.views.inc).
Notice: Undefined variable: entity_info in field_views_field_default_views_data() (line 177 av  /drupal/sites/all/modules/views/modules/field.views.inc).
Notice: Undefined variable: entity_info in field_views_field_default_views_data() (line 178 av  /drupal/sites/all/modules/views/modules/field.views.inc).
Notice: Undefined index: additional fields in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Notice: Undefined index: additional fields in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Notice: Undefined index: additional fields in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Notice: Undefined index: additional fields in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in date_field_views_data_alter() (line 252 av  /drupal/sites/all/modules/date/date_views/date_views.module).
nuez’s picture

subscribe

metalrom’s picture

subscribing

druper’s picture

Title: Custom date format not working » Custom date format not working in Views3
Project: Views (for Drupal 7) » Date
Version: 7.x-3.x-dev » 7.x-1.0-alpha2
Component: node data » Code
Issue tags: +date

subscribe

siddhy’s picture

subscribe

arlinsandbulte’s picture

Status: Active » Closed (won't fix)

Date 7.x-1.x is unsupported.
This issue should be verified in the latest version of Date (7.x-2.x-dev) and re-opened if still valid.

Thanks

dilari’s picture

I think I just ran into the same problem but using
views 7.x-3.0
and date 7.x-2.0-rc1

My custom format is: " l j M Y "
which gives: "thursday 12 jan 2012"
but in views this is rendered as: th, 12/01/2012 - 15:29

*Edit*
now that I've looked into it a little further, it seems to be a views issue. The rendered/formatted value is available in the data, but it's wrong when selecting it from the dropdown as field formatter.

arlinsandbulte’s picture

Version: 7.x-1.0-alpha2 » 7.x-2.0-rc1
Status: Closed (won't fix) » Active

I think there was an issue a while ago about needing to clear the cache for the date format to show up in views... may or may not be related (it is a D6 issue):
#277077: "Custom format" not available in Views immediately - Clearing the cache is required

dilari’s picture

thanks for the reply. Unfortunately that does not solve it. Cleared cache more than once. Also resaving the contenttype does not help.
The thing is: The formats are available but they have the wrong format.

I've posted a new issue here: http://drupal.org/node/1402922

karens’s picture

Status: Active » Fixed
dilari’s picture

Indeed it is. Thanks for that KarenS !

Petr Gromov’s picture

I don't know why, but it adds midi format to my one.
For instance, I have "9 Jan" and it is rendered as "9 Jan 9 January, 2012 - 15:15"

Petr Gromov’s picture

I have found that somehow inside date_format_date function wierd data is passed: $type is set to "custom" and $format is set to "". If I were you I vould add this validation to date_format_date function.

<?php
 function date_format_date($date, $type = 'medium', $format = '', $langcode = NULL) {
		if($format == "" && $type = "custom") return false;
...
}
?>
dilari’s picture

@Petr Gromov: You 're right. Thanks

Status: Fixed » Closed (fixed)

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

joachim’s picture

Status: Closed (fixed) » Active

I'm on 7.x-2.2. which looking at the dates should have this fix, but I'm not seeing it.

In the 'formatter' I see:
- date and time
- time ago
- plain

Both 'date and time' and 'plain' give me the same dependent dropdown, 'Choose how users view dates and times: ' which just shows the formats defined system-wide.

What I'm expecting to see is the ability to enter a PHP date format string for just this Views field, as as I can for the node creation field.

arlinsandbulte’s picture

Status: Active » Fixed

#22 is a different issue.
But, if I understand correctly, #22 is "works as designed".
You must define a custom date format at 'admin/config/regional/date-time'
Then, you can choose that format for display. Which is available globally.

This is different than the input format, where you can either choose from a list of pre-defined input formats, or create your own custom input format, which is not global, but a per-field setting.

So, there are two different date formats:
Display formats are defined globally, and any date field can use them.
Custom Input formats are defined per-field, and only that field.

PeteS’s picture

I am completely baffled by this issue. Looking through the code, it seems as though there are only two options: use the "Plain" formatter, which completely ignores whatever format is chosen, or "Date and Time," which seems to be able to apply a custom format, but to a date and time pair. I just don't understand why the architecture for the Views/Date stuff is so convoluted... isn't this like the #1 most obvious scenario that people are going to encounter when using dates in a view? To be able to control what it looks like?

joachim’s picture

Ditto.
Other Views field handlers that show dates let you give a specific format just for that field. One advantage there is that it can be baked into a Feature along with that view, whereas (AFAICT) date formats are site configuration that can't be exported.
Surely the handlers in use here can inherit from / make use of the functionality in core Views?

Status: Fixed » Closed (fixed)

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

joachim’s picture

malcolm’s picture

I've been scratching my head on this one for awhile, then revisited the Date/Time format screens. After you make your Date/Time format here: admin/config/regional/date-time/formats, you need to add it to your system here: admin/config/regional/date-time. (Holy Mother of God!)

Once you do that your custom format will show up on your Views date field format options, and on your Content Type's display options.

dealancer’s picture

It is not still not working for me in Date 2.6 and Views 3.5. Going to date formats page and saving this page solved problem for me.

jakemonO’s picture

I add a custom format (g:h A - i.e. 10:10 AM) in admin/config/regional/date-time/formats, then I create a new date type in admin/config/regional/date-time and choose the new custom time format. Then from the calendar, I choose the new type. The displayed times in my calendar view are off by varying factors. For example, one time of 4:25 PM becomes 4:04 PM in the calendar and another time of 8:45 PM becomes 8:08 PM. There doesn't seem to be any rhyme or reason to the new time values other than they are within the hour of the actual time value. If I use a system defined date type, though, all displays fine. Is this an issue with the custom formatters? I'm not really sure how to proceed with this problem...

Core: 7.23
Calendar: 7.x-3.4
Date: 7.x-2.6
Views: 7.x-3.7
Feeds: 7.x-2.0-alpha8+8-dev

UPDATE 11/17/2013 - strike this issue, I entered an incorrect custom format.