title: format time span to show hours, minutes, seconds
body: <p>I've been trying to find a simple way of formatting the output from <code>difftime</code> into HH:MM:SS.ms. So far I haven't come across anything which I was surprised by.</p>
  
  <p>I did write the function below which almost does it. The limitation is the presentation of the numbers as significant single digits. eg 2hr, 3mins, 4.5secs becomes "2:3:4.5" instead of "02:03:04.5"</p>
  
  <p>Does anyone have a better suggestion?</p>
  
  <pre><code>format.timediff &lt;- function(start_time) {
      diff = as.numeric(difftime(Sys.time(), start_time, units="mins"))
      hr &lt;- diff%/%60
      min &lt;- floor(diff - hr * 60)
      sec &lt;- round(diff%%1 * 60,digits=2)
  
      return(paste(hr,min,sec,sep=':'))
  }
  </code></pre>