EvaldoMaciel

Fluig - Formatando data (getData)

May 25th, 2020
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getData () {
  2.     var data = new Date();
  3.     var dia  = data.getDate();
  4.     var mes  = data.getMonth() + 1;
  5.     var ano  = data.getFullYear();
  6.     dia  = (dia<=9 ? "0"+dia : dia);
  7.     mes  = (mes<=9 ? "0"+mes : mes);
  8.     var novaData = ano+"/"+mes+"/"+dia;
  9.     return novaData;
  10. }
RAW Paste Data