Convert Minutes to Human Readable Days / Hours / Minutes


/ Published in: PHP
Save to your folder(s)

So. You have some minutes and want a "human readable" version? Sure thing baby!


Copy this code and paste it in your HTML
  1. $minutes = 3000;
  2. //
  3. // Assuming that your minutes value is $minutes
  4. //
  5. $d = floor ($minutes / 1440);
  6. $h = floor (($minutes - $d * 1440) / 60);
  7. $m = $minutes - ($d * 1440) - ($h * 60);
  8. //
  9. // Then you can output it like so...
  10. //
  11. echo "{$minutes}min converts to {$d}d {$h}h {$m}m";

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.