Monday, April 4, 2011

Drupal - How can I remove the 'All Day' text that is sometimes displayed at the end of a date?

The Date module allows you to use a date field in your CCK types. When you create a date field you can specify its granularity, i.e. the precision to which it stores and manipulates date data. If you specify a granularity that includes time (Hour, Minute & Second) then the date field will contain, manage and display time along with the date.
The problem arises when you enter a date into such a date field but don't bother to specify a time - you leave it blank. In this case when the date is displayed, the text '(All Day)' will be displayed after it - this can be a real pain if you want the option of time in your date but don't want this text if the user doesn't specify a time!
So, you want time in your date format but don't want this label how do you get rid of it? You might expect there to be a setting to switch this off, but it seems that there isn't, the subject is discussed in some detail here:
http://drupal.org/node/367842
and here:
http://drupal.org/node/367842
To summarise, it seems that a good way to turn it off (altogether) is just to override a theme function. Edit you template.php and add the following code:
function _date_all_day_label() {
return '';
}
This themes the all_day label to nothing. This code is taken directly from the above posts - hats off to yee lads! Make sure to replace with your theme's name, and after making the change remember to clear your cache.
I wash there was a setting for this, but is seems there isn't, this theme change worked well for me! If anybody knows of a better way of handling this please let us know!!