Last active
November 2, 2017 14:08
-
-
Save claudiohilario/62c57541ccfa87d19484078b067708e1 to your computer and use it in GitHub Desktop.
Permite Formatar a Data de Log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alert(getDateLogFormat()); | |
| /** | |
| * Devolve data atual no formato: dd-mm-yyyy hh:mm:ss.nnn | |
| * @returns {string} | |
| */ | |
| function getDateLogFormat() { | |
| var now = new Date(); | |
| var dia, mes, ano, horas, minutos, segundos, milisegundos; | |
| dia = now.getDate(); | |
| if (dia.toString().length == 1) { | |
| dia = "0" + dia; | |
| } | |
| mes = now.getMonth(); | |
| if (mes.toString().length == 1) { | |
| mes = "0" + mes; | |
| } | |
| ano = now.getFullYear(); | |
| if (ano.toString().length == 1) { | |
| ano = "0" + ano; | |
| } | |
| horas = now.getHours(); | |
| if (horas.toString().length == 1) { | |
| horas = "0" + horas; | |
| } | |
| minutos = now.getMinutes(); | |
| if (minutos.toString().length == 1) { | |
| minutos = "0" + minutos; | |
| } | |
| segundos = now.getSeconds(); | |
| if (segundos.toString().length == 1) { | |
| segundos = "0" + segundos; | |
| } | |
| milisegundos = now.getMilliseconds(); | |
| if (milisegundos.toString().length == 1) { | |
| milisegundos = milisegundos + "0"; | |
| } | |
| return dia + '-' + mes + '-' + ano + ' ' + horas + ':' + minutos + ':' + segundos + '.' + milisegundos; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment