Skip to content

Instantly share code, notes, and snippets.

@tamalw
Created July 28, 2008 20:04
Show Gist options
  • Save tamalw/2945 to your computer and use it in GitHub Desktop.
Save tamalw/2945 to your computer and use it in GitHub Desktop.
require 'date'
class DateTime
def to_f
days_since_unix_epoch = self - ::DateTime.civil(1970)
(days_since_unix_epoch * 86_400).to_f
end
end
foo = DateTime.now
puts foo.to_f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment