From: Colin Bartlett Date: 2011-01-01T05:54:33+09:00 Subject: Re: change integer into date These might help? Date#jd gives you the Julian Day Number of a date, and the Julian Day Number of 1970-01-01 (Gregorian) is 2440588, so you can do things like the following. There is also the DateTime class, which I have not used until this post. "Date" also adds Time#to_date and Time#to_datetime, but I haven't tried those. IRB in Ruby 1.9.1 require "date" biaozun = Date.new( 1970, 1, 1 ) #=> # duration_secs = 1_262_222_200 #=> 1262222200 duration_days_rational = duration_secs.quo( 86400 ) #=> (6311111/432) duration_days_integer = duration_secs.div( 86400 ) #=> 14609 duration_days_integer2 = duration_secs / 86400 #=> 14609 date2 = biaozun + duration_days_integer #=> # exit unix_date_zero_jd = biaozun.jd #=> 2440588 d2jd = date2.jd #=> 2455197 dur2_secs = (d2jd - 2440588) * 86400 #=> 1262217600 ut = Time.at( dur2_secs ) #=> 2009-12-31 00:00:00 +0000 dt = DateTime.new( 2010, 12, 31, 13, 42 ) #=> # t = dt.to_time #=> 2010-12-31 13:42:00 +0000 t2 = date2.to_time #=> 2009-12-31 00:00:00 +0000