Skip to content

Instantly share code, notes, and snippets.

@mrpunkin
Created July 6, 2012 17:36
Show Gist options
  • Save mrpunkin/3061527 to your computer and use it in GitHub Desktop.
Save mrpunkin/3061527 to your computer and use it in GitHub Desktop.
def time_left(timestamp)
diff = timestamp - Time.zone.now
d = (diff / 86400).floor
h = ((diff / 3600) % 24).floor
m = ((diff / 60) % 60).round
{:days=>d, :hours=>h, :minutes=>m}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment