Answer by Phrogz for Convert Ruby Date to Integer
t = Time.now# => 2010-12-20 11:20:31 -0700# Seconds since epocht.to_i#=> 1292869231require 'date'd = Date.today#=> #<Date: 2010-12-20 (4911101/2,0,2299161)>epoch =...
View ArticleAnswer by EnabrenTane for Convert Ruby Date to Integer
Time.now.to_ireturns seconds since epoch format
View ArticleAnswer by Nowaker for Convert Ruby Date to Integer
Solution for Ruby 1.8 when you have an arbitrary DateTime object:1.8.7-p374 :001 > require 'date' => true 1.8.7-p374 :002 > DateTime.new(2012, 1, 15).strftime('%s') => "1326585600"
View ArticleAnswer by user9153631 for Convert Ruby Date to Integer
Date cannot directly become an integer. Ex:$ Date.today=> #<Date: 2017-12-29 ((2458117j,0s,0n),+0s,2299161j)>$ Date.today.to_i=> NoMethodError: undefined method 'to_i' for #<Date:...
View ArticleAnswer by Wagner Braga for Convert Ruby Date to Integer
I had to do it recently and took some time to figure it out but that is how I came across a solution and it may give you some ideas:require 'date'today = Date.todayyear = today.yearmonth = today.monday...
View ArticleAnswer by Pelle for Convert Ruby Date to Integer
I'm incredibly surprised that nobody has given what I believe to be the most correct answer to this.Since Ruby 1.9.3, Dates can be converted from and to integers. To get the julian day number for any...
View Article