Posted By

rocktronica on 06/18/09


Tagged

php time convert hours minutes seconds


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

rocktronica
BrianCoyDesign


Convert hh:mm:ss to Seconds


 / Published in: PHP
 

URL: http://iamnotagoodartist.com/

This works, though I'm not 100% sure it's the most streamlined way to do it. If you've got a better idea, give me a holler!

  1. function hms2sec ($hms) {
  2. list($h, $m, $s) = explode (":", $hms);
  3. $seconds = 0;
  4. $seconds += (intval($h) * 3600);
  5. $seconds += (intval($m) * 60);
  6. $seconds += (intval($s));
  7. return $seconds;
  8. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jc on June 23, 2009

Nice and clean! A lighter version is available here

Posted By: rocktronica on July 26, 2009

Spam much?

You need to login to post a comment.