# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  before_filter :timeframe
  
  def timeframe
    @today = Time.zone.today
    @conditions = ["created_at > :start_date and created_at <= :end_date", {
      :start_date => @today.beginning_of_day.utc, 
      :end_date   => @today.end_of_day.utc
    }]
    @conditions = ["created_at > :start_date and created_at <= :end_date", {
      :start_date => Time.parse(params[:start_date]).to_date.beginning_of_day.utc, 
      :end_date   => Time.parse(params[:end_date]).to_date.end_of_day.utc
    }] if params[:start_date] && params[:end_date]
  end
  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password
end

# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  before_filter :timeframe
  
  def timeframe
    @today = Date.today.to_time.utc
    @conditions = ["created_at > :start_date and created_at <= :end_date", {
      :start_date => @today, 
      :end_date   => @today + 1.day
    }]
    @conditions = ["created_at > :start_date and created_at <= :end_date", {
      :start_date => Time.parse(params[:start_date]).to_date.to_time.utc, 
      :end_date   => Time.parse(params[:end_date]).to_date.to_time.utc + 1.day
    }] if params[:start_date] && params[:end_date]
  end
  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password
end

--- 
+++ 
@@ -6,14 +6,14 @@
   before_filter :timeframe
   
   def timeframe
-    @today = Date.today.to_time.utc
+    @today = Time.zone.today
     @conditions = ["created_at > :start_date and created_at <= :end_date", {
-      :start_date => @today, 
-      :end_date   => @today + 1.day
+      :start_date => @today.beginning_of_day.utc, 
+      :end_date   => @today.end_of_day.utc
     }]
     @conditions = ["created_at > :start_date and created_at <= :end_date", {
-      :start_date => Time.parse(params[:start_date]).to_date.to_time.utc, 
-      :end_date   => Time.parse(params[:end_date]).to_date.to_time.utc + 1.day
+      :start_date => Time.parse(params[:start_date]).to_date.beginning_of_day.utc, 
+      :end_date   => Time.parse(params[:end_date]).to_date.end_of_day.utc
     }] if params[:start_date] && params[:end_date]
   end
   # Scrub sensitive parameters from your log
Use application timezone (not server timezone) for determining default time frame.

Also use beginning_of_day and end_of_day methods for setting time frame limits.
