Skip to content

Instantly share code, notes, and snippets.

@whizcreed
Created July 28, 2011 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whizcreed/1111443 to your computer and use it in GitHub Desktop.
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
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