Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now
3 Responses to Edge Rails: Time#current
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?
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?
[…] This post was mentioned on Twitter by Akhil Bansal, Rails Bot. Rails Bot said: Edge Rails: Time#current http://bit.ly/bIoEfi […]
a more concise way to do this is Date.current