timeformat

time_format
SYNOPSIS

time_format($n, $d=false)

DESCRIPTION
CODE
  1. function time_format($n, $d=false) {
  2.     if ($n < 0) {
  3.         return 0;
  4.     }
  5.  
  6.     if ($n < 60) {
  7.         return sprintf('%ds', $n);
  8.     }
  9.  
  10.     if ($n < 3600) {
  11.         return sprintf('%dm%02ds', $n / 60, $n % 60);
  12.     }
  13.  
  14.     if ($n < 24*3600 or $d === false) {
  15.         return sprintf('%dh%02dm%02ds', $n / 3600, ($n / 60) % 60, $n % 60);
  16.     }
  17.  
  18.     return sprintf('%d%s%02dh%02dm%02ds', $n / (24*3600), $d, ($n / 3600) % 24, ($n / 60) % 60, $n % 60);
  19. }

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].