juniorsabbath

hora formato HH:MM:SS js

Sep 5th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. //declarando las hora para notificaciones
  2. var fecha = new Date();
  3. var hora = fecha.getHours();
  4. var minutos = fecha.getMinutes();
  5. var segundos = fecha.getSeconds();
  6.  
  7. //aquĆ­ se hace lo 'importante'
  8. if(hora<10){hora='0'+hora}
  9. if(minutos<10){minutos='0'+minutos}
  10. if(segundos<10){segundos='0'+segundos}
  11.  
  12. //Agrupando a la variable
  13. var horacompleta = ' - A las: '+hora+':'+minutos+':'+segundos;
Advertisement
Add Comment
Please, Sign In to add comment