Skip to content

Instantly share code, notes, and snippets.

@dimaspante
Last active April 13, 2022 03:15
Show Gist options
  • Save dimaspante/1a777234fe5050383b54855c55371f08 to your computer and use it in GitHub Desktop.
Save dimaspante/1a777234fe5050383b54855c55371f08 to your computer and use it in GitHub Desktop.
Exibe a hora e data por extenso no campo id dt_inscricao
function mostrarDataHora(){
var hoje = new Date();
//https://stackoverflow.com/questions/24998624/day-name-from-date-in-js
var days = ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'];
var mons = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var nome = days[hoje.getDay()];
var data = nome + ', ' + ("0" + hoje.getDate()).slice(-2) + ' de ' + mons[hoje.getMonth()] + ' de ' + hoje.getFullYear();
var hora = ("0" + hoje.getHours()).slice(-2) + ":" + ("0" + hoje.getMinutes()).slice(-2) + ":" + ("0" + hoje.getSeconds()).slice(-2);
document.getElementById("dt_inscricao").value = hora + ' - ' + data;
}
window.onload = function(){
mostrarDataHora();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment