/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def days_between(date1, date2) yyyy1,mm1,dd1 = $3, $1, $2 if date1 =~ /(\d+)\/(\d+)\/(\d+)/ date1_ts = Time.mktime(yyyy1,mm1,dd1).tv_sec yyyy2,mm2,dd2 = $3, $1, $2 if date2 =~ /(\d+)\/(\d+)\/(\d+)/ date2_ts = Time.mktime(yyyy2,mm2,dd2).tv_sec (date2_ts - date1_ts)/60/60/24 end