Ejemplo 1: fecha de JavaScript de hoy dd mm aaaa
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 + "https://foroayuda.es/" + dd + "https://foroayuda.es/" + yyyy;
document.write(today);
Ejemplo 2: fecha de conversión de JavaScript a aaaa-mm-dd
// `date` is a `Date` object
const formatYmd = date => date.toISOString().slice(0, 10);
// Example
formatYmd(new Date()); // 2020-05-06
Ejemplo 3: fecha de formato javascript aaaa-mm-dd
let today = new Date()
today.toISOString().split('T')[0]
Ejemplo 4: formato de fecha js aaaa-mm-dd
yourDate.toISOString().split('T')[0]
Ejemplo 5: obtener la fecha actual javascript aaaa-mm-dd
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 = year+"-"+month+"-"+day;
alert(formattedDate); //2021-02-28
Ejemplo 6: getdate aaaa mm dd formato javascript
let today = new Date();
let dd = today.getDate();
let mm = today.getMonth()+1;
const yyyy = today.getFullYear();
if(dd<10)
{
dd=`0${dd}`;
}
if(mm<10)
{
mm=`0${mm}`;
}
today = `${mm}-${dd}-${yyyy}`;
console.log(today);
today = `${mm}/${dd}/${yyyy}`;
console.log(today);
today = `${dd}-${mm}-${yyyy}`;
console.log(today);
today = `${dd}/${mm}/${yyyy}`;
console.log(today);
// GET FUll DATE WITH DAY, MONTH and YEARS
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)