How to Subtract Time in Rails? -
i'm new ruby , rails. have time type column in db stores user time inputs form.
<div class="col-md-12">    <%= form_for(gotime.new) |f| %>     <%= f.time_select :hours%>     <%= f.submit "submit" %>     <% end %> </div> i need subtract x minutes gotime.last new time. seems in order need somehow set gotime starting time count Х minutes back. how can this? idea correct or should done other way?
if have time column 
gotime.last.time - 3.minutes
if have hours , minutes column , want subtract time minutes :
obj = gotime.last  time = datetime.now.change({ hour: obj.hours, min: obj.minutes, sec: 0 })  time - 3.minutes if have date time can replace datetime.now it
Comments
Post a Comment