Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'date'
- start_time = "2012-03-02 14:46:21"
- today_date = Time.now.strftime("%Y-%d-%m %H:%M;%S")
- end_time = "2017-04-02 14:46:21"
- st, nt, et = [start_time, now, end_time].map do |t|
- # convert to unix timestamp, as float
- DateTime.parse(t).strftime('%s').to_f
- end
- result = (nt - st) / (et - st) # assumes start < today < end
Add Comment
Please, Sign In to add comment