Created
July 28, 2011 12:18
-
-
Save whizcreed/1111443 to your computer and use it in GitHub Desktop.
Rails how to round time to the current hour. 05:12:03 to 05:00:00
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = Time.now.utc | |
t.sec.seconds.ago(((t.min).minutes.ago(t))) | |
# Aditya Raj: http://whizcreed.com | |
=begin | |
>> t = Time.now.utc | |
=> Thu Jul 28 12:13:26 UTC 2011 | |
>> t.sec.seconds.ago(((t.min).minutes.ago(t))) | |
=> Thu Jul 28 12:00:00 UTC 2011 | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment