“JavaScript Format Date to dd-mm-yyyy” Respostas de código

JavaScript Obtenha data atual aaaaa-dd

var todayDate = new Date().toISOString().slice(0, 10);
console.log(todayDate);
 Run code snippet
Code Alchemy

JavaScript Data hoje DD mm

var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();

today = mm + '/' + dd + '/' + yyyy;
document.write(today);
Charlie

Data do formato JavaScript

let today = new Date()
today.toISOString().split('T')[0]
Beautiful Bug

Objeto de data do formato JavaScript para AAAA-MM-DD

const yourDate = new Date()
yourDate.toISOString().split('T')[0]
Determined Dormouse

JavaScript Format Date to dd-mm-yyyy

function pad2(n) {
  return (n < 10 ? '0' : '') + n;
}

var date = new Date();
var month = pad2(date.getMonth()+1);//months (0-11)
var day = pad2(date.getDate());//day (1-31)
var year= date.getFullYear();

var formattedDate =  day+"-"+month+"-"+year;
alert(formattedDate); //28-02-2021
Friendly Hawk

Converta um novo padrão de data em um formato AAAA-MM-DD em JavaScript

function convert(str) {
  var date = new Date(str),
    mnth = ("0" + (date.getMonth() + 1)).slice(-2),
    day = ("0" + date.getDate()).slice(-2);
  return [date.getFullYear(), mnth, day].join("-");
}

console.log(convert("Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)"))
//-> "2011-06-08"
Nutty Narwhal

Respostas semelhantes a “JavaScript Format Date to dd-mm-yyyy”

Perguntas semelhantes a “JavaScript Format Date to dd-mm-yyyy”

Mais respostas relacionadas para “JavaScript Format Date to dd-mm-yyyy” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código