Is Time.zone.now.to_date equivalent to Date.today?

They are not always the same. Time.zone.now.to_date will use the applications time zone, while Date.today will use the servers time zone. So if the two lie on different dates then they will be different. An example from my console:

ruby-1.9.2-p290 :036 > Time.zone = "Sydney"
 => "Sydney" 
ruby-1.9.2-p290 :037 > Time.zone.now.to_date
 => Wed, 21 Sep 2011 
ruby-1.9.2-p290 :038 > Date.today
 => Tue, 20 Sep 2011 

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)