Advertisement
ralfting

getTime()

Mar 26th, 2014
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Pega tempo
  2. function getTime(){
  3.     var horaInicio      = new Date();
  4.     var minutos         = horaInicio.getMinutes();
  5.     var segundos        = horaInicio.getSeconds();
  6.     var milisegundos    = horaInicio.getMilliseconds();
  7.     var arrTempo = [minutos, segundos, milisegundos];
  8.     var tempo = arrTempo.join();
  9.     return tempo;
  10. }
  11.  
  12. // calcula tempo de execução
  13.     function tempoExecucao(tempoInicio, tempoFim){
  14.         var tempoInicioCalc = tempoInicio.split(",");
  15.         var tempoFinalCalc = tempoFim.split(",");
  16.         // calculo do tempo
  17.         var calcMinuto          = tempoFinalCalc[0]-tempoInicioCalc[0];
  18.         var calcSegundo         = tempoFinalCalc[1]-tempoInicioCalc[1];
  19.         var calcMilisegundos    = tempoFinalCalc[2]-tempoInicioCalc[2];
  20.         // une em uma array
  21.         var tempoCalc = [calcMinuto, calcSegundo, calcMilisegundos];
  22.         // une em uma string
  23.         tempoCalc.join();
  24.         return tempoCalc;
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement