• RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

Edge Rails: Time#current

Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now

3 Responses so far.

  1. taelor says:

    protip: If your website deals heavily with different Time Zones, you need to use Time.current.to_date instead of Date.today when automatically setting the date for some attribute.

    For instance, if your server is in the Eastern Time Zone, and someone is using the system at 11 PM in the Pacific time zone, you will get the wrong date.

    Anyone have any comments about overriding Date.today to use Time.current.to_date when config.time_zone is set? Good idea or bad idea that might get you in trouble?

  2. [...] This post was mentioned on Twitter by Akhil Bansal, Rails Bot. Rails Bot said: Edge Rails: Time#current http://bit.ly/bIoEfi [...]

  3. hubert says:

    a more concise way to do this is Date.current


Asset Pipeline has been extracted a...

The asset pipeline which was introduced in Rails 3.1, has ...

ClientSideValidations: Add/Map mode...

#/status/256699237230845952

Action and Page caching has been ex...

With the commit c82cf81f00f Action and Page caching has been extracted ...

turbo-sprockets-rails3: Speeds up ...

#/status/253420357841723393

EdgeRails: ActiveRecord::SessionSto...

With the commit 3324e28804 ActiveRecord::SessionStore is extracted out of Rails into ...

Asset Pipeline has been extracted a...

The asset pipeline which was introduced in Rails 3.1, has ...

ClientSideValidations: Add/Map mode...

#/status/256699237230845952

Action and Page caching has been ex...

With the commit c82cf81f00f Action and Page caching has been extracted ...

turbo-sprockets-rails3: Speeds up ...

#/status/253420357841723393

EdgeRails: ActiveRecord::SessionSto...

With the commit 3324e28804 ActiveRecord::SessionStore is extracted out of Rails into ...