title: convert time DD:hh:mm:ss format into seconds in Rails 3
body: <p>I need to get time value of DD:hh:mm:ss into seconds. Value is an output from a postgresql db query and looks something like this:</p>
  
  <pre><code>db_value = '456:14:56:10'
  </code></pre>
  
  <p>and I need to get it into seconds, I have an method in my application which does vice versa like this: </p>
  
  <pre><code>def time_converter(seconds)
    days = seconds / 86400
    seconds -= days * 86400
    hours = seconds / 3600
    seconds -= hours * 3600         
    minutes = seconds / 60
    seconds -= minutes * 60
    return "#{days}:#{hours}:#{minutes}:#{seconds}"
  </code></pre>
  
  <p>Can I use this method somehow or is it possible to change format in postgresql into seconds? What is the most efficient way of doing it?</p>
  
  <p>db value is part of a SUM((end_time - start_time)* multiplier) AS duration query.</p>