Advertisement
garfield

[PHP]: Função para converter tempo

Jan 30th, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. /*
  2.         @Função: Converter tempo
  3.         @Creditos: SuYaNw
  4.  
  5.         suyanwdacio.blogspot.com
  6. */
  7.  
  8.  
  9. function Calcular($numero, $tempo)
  10. {
  11.     $var_tempo = 0;
  12.     $string = "";
  13.     $var_saida = 0;
  14.     $out = "";
  15.     switch($tempo)
  16.     {
  17.         case 0: $var_tempo = 1000; $string = "Segundo(s)";  break;// segundo
  18.         case 1: $var_tempo = 60000; $string = "Minuto(s)";  break;  // minuto
  19.         case 2: $var_tempo = 3600000; $string = "Hora(s)";  break;  // horida
  20.         case 3: $var_tempo = 86400000; $string = "Dia(s)";  break;  // dia
  21.         case 4: $var_tempo = 86400000; $string = "Semana(s)"; break;    // semana
  22.         case 5: $var_tempo = 2592000000; $string = "Mes(es)"; break;    // mes
  23.         case 6: $var_tempo = 2592000000 * 12; $string = "Ano(s)";   break;// ano
  24.         default: $var_tempo8 = 5;
  25.     }
  26.     if($var_tempo != 5)
  27.     {
  28.         $var_saida =  $numero * $var_tempo;
  29.         $out = $var_saida." ".$string;
  30.     }
  31.     else
  32.     {
  33.         $out = "Tempo inválido";
  34.     }
  35.     return $out;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement