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 ""
Replace :

function date_parts_form(....
$format = $this->date_handler->views_formats($this->options['granularity'], 'sql');

function date_parts_form(....
$format = $this->date_handler->views_formats($this->options['granularity'], 'display');


function views_formats(...
$long = str_replace(':i', ':i:s', variable_get('date_format_long',  'l, F j, Y - H:i'));


function views_formats(...
$long = str_replace(':i', ':i:s', variable_get('date_format_short',  'l, F j, Y - H:i'));


Category:bug» feature

Not a bug report.

Version:6.x-2.0» 6.x-2.x-dev
Status:Needs work» Needs review
new4.13 KB

I had the same need, the attached patch did the trick for me

graoxx stuff works for me, plach patch didnt :-)

#2 patch
no problems with date 2.4 and views 2.8

First hack worked for me.

Works great outta the box. Just aply for views 2.8 Date 2.4

This works, but will it be integrated in a newer version? And what other functionality is affected by this?

@plach nice work! no probs here

Status:Needs review» Reviewed & tested by the community

It looks like this is RTBC, let's get a word from Karen.

will this work for views 3?

Hey there,

am I missing something or has date module changed? I can't find a file called inside my date module folder.



Hoping this gets committed, I'm getting tired of patching date all the time.

This doesn't seem to work for me but here's another solution

// Called from hook_form_alter ...
function _mymodule_views_exposed_form_alter(&$form, $form_state) {
array_unshift($form['#submit'], 'mymodule_views_exposed_form_submit');
* Ensure the system recognises the dates aren't American.
function mymodule_views_exposed_form_submit($form, &$form_state) {
  if (isset(
$form_state['values']['post_date'])) {
$form_state['values']['post_date'] as $key => $value) {
$form_state['values']['post_date'][$key] = str_replace('/', '-', $value);

Basically according to 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

+1 for commit

Category:feature» bug

actually this _is_ a bug report as the filter won't work at all with locale dates and without this patch, so please commit it :)

Please commit this, customers are going caaraaaazy about this :/



Status:Reviewed & tested by the community» Needs work

I 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 :)

Actually it is *three* approaches -- one a complete patch and two that are just descriptions of a fix.

#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.

Like 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').

Did 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

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?

Status:Needs work» Needs review
new4.78 KB

As 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

  1. Line #65 of my patch - this seems flimsy and probably needs some checks, like is Views installed?
  2. Does this work with select date types?

Status:Needs review» Reviewed & tested by the community

works like a charm


works perfectly for me.
Thanks for the patch mstrelan..

any chance on being commited?

Status:Reviewed & tested by the community» Needs work

ok actually i take it breaks my forms...any forms that use popup with FAPI...

function test_form() {
$form['test-from'] = array(
'#type' => 'date_popup',
'#title' => 'From',
'#date_format' => 'Y-m-d',
'#date_year_range' => '-3:+0',
$form['test-to'] = array(
'#type' => 'date_popup',
'#title' => 'To',
'#date_format' => 'Y-m-d',
'#date_year_range' => '-3:+0',
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
get_user_stats_form_submit($form_id, $form_values) {

returns -0001-11-30 00:00:00 no matter what date i choose in the form using popup calendar :/


Does this issue still make sense? Does it apply to 7.x?