I have these dates and times:
schedule.day_start # => 2014-09-27 15:30:00 UTC
date_now = Time.now # => 2014-09-27 15:11:14 +0200
date_now + 60.minutes # => 2014-09-27 16:11:14 +0200
I am trying to detect all schedules that start 60 minutes or less before day_start
. With the following code, I get as a response "NO"
instead of "YES"
.
if schedule.day_start < (Time.now + 60.minutes)
"YES"
else
"NO"
end
Why is 2014-09-27 15:30:00 UTC
bigger than 2014-09-27 16:11:14 +0200
?
Work them dates as UTC, so you will avoid time zone problems
if schedule.day_start.utc < (Time.now + 60.minutes).utc
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With