“Holen Sie sich das Datumsformat JavaScript” Code-Antworten

JavaScript konvertieren Datum in Yyyy-MM-DD

// `date` is a `Date` object
const formatYmd = date => date.toISOString().slice(0, 10);

// Example
formatYmd(new Date());      // 2020-05-06
Batman

JavaScript -Datumsformat

var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today  = new Date();

console.log(today.toLocaleDateString("en-US")); // 9/17/2016
console.log(today.toLocaleDateString("en-US", options)); // Saturday, September 17, 2016
console.log(today.toLocaleDateString("hi-IN", options)); // शनिवार, 17 सितंबर 2016
Spongey Bob

Formatdatum js

var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today  = new Date();

console.log(today.toLocaleDateString("en-US")); // 9/17/2016
console.log(today.toLocaleDateString("en-US", options)); // Saturday, September 17, 2016

 // For custom format use
 date.toLocaleDateString("en-US", { day: 'numeric' })+ "-"+ date.toLocaleDateString("en-US", { month: 'short' })+ "-" + date.toLocaleDateString("en-US", { year: 'numeric' }) // 16-Nov-2019
Nemesis

Formatdatum js

const t = new Date();
const date = ('0' + t.getDate()).slice(-2);
const month = ('0' + (t.getMonth() + 1)).slice(-2);
const year = t.getFullYear();
const hours = ('0' + t.getHours()).slice(-2);
const minutes = ('0' + t.getMinutes()).slice(-2);
const seconds = ('0' + t.getSeconds()).slice(-2);
const time = `${date}/${month}/${year}, ${hours}:${minutes}:${seconds}`;

output: "27/04/2020, 12:03:03"
Drab Dingo

JavaScript -Formatdatum

var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today  = new Date();

console.log(today.toLocaleDateString("en-US")); // 9/17/2016
console.log(today.toLocaleDateString("en-US", options)); // Saturday, September 17, 2016
console.log(today.toLocaleDateString("hi-IN", options)); 
Sironicas

Holen Sie sich das Datumsformat JavaScript

  //Date format
  const handleDate = (dataD) => {
    let data= new Date(dataD)
    let month = data.getMonth() + 1
    let day = data.getDate()
    let year = data.getFullYear()
    if(day<=9)
      day = '0' + day
    if(month<10)
      month = '0' + month
    const postDate = year + '-' + month + '-' + day
    return postDate
  }
Volcano

Ähnliche Antworten wie “Holen Sie sich das Datumsformat JavaScript”

Fragen ähnlich wie “Holen Sie sich das Datumsformat JavaScript”

Weitere verwandte Antworten zu “Holen Sie sich das Datumsformat JavaScript” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen