Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Date Format is always 'sql' when a filter is added to a view. Even if the filter is exposed.
In my case, I need to display 'local' date format.
I modify some code, I hope it could help you, I think you need to change it :
In "date_api_filter_handler.inc"
Replace :
function date_parts_form(....
...
$format = $this->date_handler->views_formats($this->options['granularity'], 'sql');
By
function date_parts_form(....
...
$format = $this->date_handler->views_formats($this->options['granularity'], 'display');
In date_api_sql.inc
Replace
function views_formats(...
...
$long = str_replace(':i', ':i:s', variable_get('date_format_long', 'l, F j, Y - H:i'));
By
function views_formats(...
...
$long = str_replace(':i', ':i:s', variable_get('date_format_short', 'l, F j, Y - H:i'));
Comment | File | Size | Author |
---|---|---|---|
#24 | 392836-Date-Exposed-Date-filter-format-in-Views.patch | 4.78 KB | mstrelan |
#2 | date-392836-2.patch | 4.13 KB | plach |
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedNot a bug report.
Comment #2
plachI had the same need, the attached patch did the trick for me
Comment #3
Marko B CreditAttribution: Marko B commentedgraoxx stuff works for me, plach patch didnt :-)
Comment #4
cels CreditAttribution: cels commented#2 patch
no problems with date 2.4 and views 2.8
Comment #5
Iztok CreditAttribution: Iztok commentedFirst hack worked for me.
Comment #6
pokadan CreditAttribution: pokadan commentedWorks great outta the box. Just aply for views 2.8 Date 2.4
Comment #7
djschoone CreditAttribution: djschoone commentedThis works, but will it be integrated in a newer version? And what other functionality is affected by this?
Comment #8
scottrigby@plach nice work! no probs here
Comment #9
plachIt looks like this is RTBC, let's get a word from Karen.
Comment #10
YK85 CreditAttribution: YK85 commentedwill this work for views 3?
thanks!
Comment #11
Daniel Wentsch CreditAttribution: Daniel Wentsch commentedHey there,
am I missing something or has date module changed? I can't find a file called date_api_sql.inc inside my date module folder.
Cheers,
klickreflex
Comment #12
bibo CreditAttribution: bibo commented+Subscribe.
Hoping this gets committed, I'm getting tired of patching date all the time.
Comment #13
mstrelan CreditAttribution: mstrelan commentedThis doesn't seem to work for me but here's another solution
Basically according to http://www.php.net/manual/en/datetime.formats.date.php PHP will only assume its an American date format if it uses a forward slash. As far as I know Australians also use forward slashes and therefore are likely to type in forward slashes. These are converted to hyphens and the system searches in Australian (normal) format
Comment #14
YK85 CreditAttribution: YK85 commented+1 for commit
Comment #15
gunzip CreditAttribution: gunzip commentedactually this _is_ a bug report as the filter won't work at all with locale dates and without this patch, so please commit it :)
Comment #16
Shademan CreditAttribution: Shademan commentedPlease commit this, customers are going caaraaaazy about this :/
Comment #17
cossme CreditAttribution: cossme commentedsubscribing
Comment #18
galaxor CreditAttribution: galaxor commentedsubscribing
Comment #19
KarenS CreditAttribution: KarenS commentedI see two approaches, one a patch and one not, and numerous reports that one or the other didn't work. This is not a single patch that everyone agrees will work, it is two patches with some people saying one works and some saying the other works.
Please clean this up if you want me to commit it :)
Comment #20
KarenS CreditAttribution: KarenS commentedActually it is *three* approaches -- one a complete patch and two that are just descriptions of a fix.
Comment #21
gunzip CreditAttribution: gunzip commented#2 works for me (view 6.x-2.11 - date 6.x-2.6)
i suspect ppl that says it does not work didn't changed/apply the correct view filter settings.
Comment #22
killua99 CreditAttribution: killua99 commentedLike gunzip,
#2 works for me (view 6.x-2.12 - date 6.x-2.7)
You need select the DATE FORMAT under the type input date (is a textfield and you need something like 'm-d-Y').
Comment #23
mstrelan CreditAttribution: mstrelan commentedDid anybody try this with date_popup?
I have been able to apply #2 and set my format to d/m/Y however it only works with text (have not tried select). Does not work with popup, which would be why I posted my own solution in #13.
My query string
date_filter[min][date]=1/05/2011&date_filter[max][date]=31/5/2011
Query output
AND ((DATE_FORMAT(ADDTIME(node_data_field_event_session_date_time.field_event_session_date_time_value, SEC_TO_TIME(node_data_field_event_session_date_time.field_event_session_date_time_offset)), '%Y-%m-%d') >= '0001-11-30' AND DATE_FORMAT(ADDTIME(node_data_field_event_session_date_time.field_event_session_date_time_value, SEC_TO_TIME(node_data_field_event_session_date_time.field_event_session_date_time_offset)), '%Y-%m-%d') <= '0001-11-30') AND (DATE_FORMAT(ADDTIME(node_data_field_event_session_date_time.field_event_session_date_time_value2, SEC_TO_TIME(node_data_field_event_session_date_time.field_event_session_date_time_offset)), '%Y-%m-%d') >= '0001-11-30' AND DATE_FORMAT(ADDTIME(node_data_field_event_session_date_time.field_event_session_date_time_value2, SEC_TO_TIME(node_data_field_event_session_date_time.field_event_session_date_time_offset)), '%Y-%m-%d') <= '0001-11-30')
I will keep trying to see if I can find the solution.
KarenS, thank you for taking the time to look at our messy and incomplete issue. I think what we are looking for is not just a commit, but with your expertise with the Date module perhaps you could provide some advice?
Comment #24
mstrelan CreditAttribution: mstrelan commentedAs usual I have found the solution soon after commenting so here is my patch. It is based on #2 but includes support for date_popup.
Before RTBC we need to review the following
Comment #25
gibus CreditAttribution: gibus commentedworks like a charm
Comment #26
arrebucio CreditAttribution: arrebucio commentedsubscribing...
Comment #27
ParisLiakos CreditAttribution: ParisLiakos commentedworks perfectly for me.
Thanks for the patch mstrelan..
any chance on being commited?
Comment #28
ParisLiakos CreditAttribution: ParisLiakos commentedok actually i take it back..it breaks my forms...any forms that use popup with FAPI...
returns -0001-11-30 00:00:00 no matter what date i choose in the form using popup calendar :/
Comment #29
hlykos CreditAttribution: hlykos commentedsubscribe
Comment #30
klonosDoes this issue still make sense? Does it apply to 7.x?
Comment #31
Chris CharltonStill an issue?
Comment #32
DamienMcKennaUnfortunately the D6 version of this module is no longer supported, but we appreciate the time you put into this. If this problem is relevant for D7 too, please reopen the issue. Thanks.