计算两个日期相隔的天数
#计算两个php?name=%C8%D5%C6%DA" onclick="tagshow(event)" class="t_tag">日期之间相隔的天数时分秒
#Jack 2008年2月22日 11时08分55秒
def SecToDateTime(seconds)
time = seconds.round # Get rid of microseconds
second = time % 60 # Extract seconds
time /= 60 # Get rid of seconds
minutes = time % 60 # Extract minutes
time /= 60 # Get rid of minutes
hours = time % 24 # Extract hours
time /= 24 # Get rid of hours
days = time # Days (final remainder)
[days, hours, minutes, second] # Return array [d,h,m,s]
end
t1 = Time.mktime(2008,8,8,20,0,0)
t2 = Time.now
result = SecToDateTime(t1-t2)
puts "距第29届(北京)奥运会开幕:"
printf "%d 天 %d 时 %d 分 %d 秒",result[0],result[1],result[2],result[3]