Is there a way to convert postgres UTC time to the user's timezone or at the very least Eastern Standard Time (I'd be grateful with either answer)?
I thought that there was a way to change postgres UTC time, but I don't think there is without causing a lot of issues. From what I read it would be better to use code on the frontend that would convert it to the correct time zone?
This barely makes sense to me.
What's the point?
So that when a user checks off he completed a good habit, the habit disappears, and is suppose to reshow tomorrow at 12am, but the habits end up reshowing later in the day because of UTC.
habit.rb
scope :incomplete, -> {where("completed_at is null OR completed_at < ?", Date.today)} # aka those habits not completed today will be shown
def completed=(boolean)
self.completed_at = boolean ? Time.current : nil
end
def completed
completed_at && completed_at >= Time.current.beginning_of_day
end
config.time_zone = 'Eastern Time (US & Canada)'in your application.rb and in your console if you do Habit.last.completed_at does it returns UTC time or Eastern time.?Time.zone.noworTime.zone.beginning_of_day. if you change your scope abit and addconfig.time_zone = 'Eastern Time (US & Canada)'in your application.rb you will acheive what you wantHabit.last.completed_atwhat does it return. also change your scope like thisscope :incomplete, -> {where("completed_at is null OR completed_at < ?", Time.zone.now.beginning_of_day)}Sun, 26 Jul 2015 12:20:13 EDT -04:00It works in development @Athar. I'll give that scope a try.