Skip to content

Instantly share code, notes, and snippets.

@brunolimadevelopment
Created March 24, 2020 19:30
Show Gist options
  • Save brunolimadevelopment/b382c335ba4e2c481c6428a7d0cc4bf2 to your computer and use it in GitHub Desktop.
Save brunolimadevelopment/b382c335ba4e2c481c6428a7d0cc4bf2 to your computer and use it in GitHub Desktop.
[JS] - INSERINDO DATA ATUAL NO CAMPO DO FORMULÁRIO
// CRIA OBJETO DATA - JS
var data = new Date();
var dia = data.getDate().toString();
var diaF = ( dia.length == 1 ) ? '0' + dia : dia;
var mes = ( data.getMonth() + 1 ).toString();
var mesF = ( mes.length == 1 ) ? '0' + mes : mes;
var anoF = data.getFullYear();
var data = diaF + '/' + mesF + '/' + anoF;
var elFiled = document.getElementById('data');
elFiled.setAttribute('value', data);
// HTML
<input type="hidden" name="data" id="data">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment