31 lines
1003 B
HTML
31 lines
1003 B
HTML
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Übung 05: formatDate Fehler</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" />
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<div class="container py-5">
|
|
<div class="alert alert-primary">
|
|
<h2>Übung 05: formatDate Fehler</h2>
|
|
<p>Die Kommentare zeigen das erwartete Ergebnis.</p>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<script>
|
|
'use strict';
|
|
function formatDate(date) {
|
|
const options = { year: 'numeric', month: 'long', day: 'numeric' };
|
|
const formatedDate = date.toLocaleDateString('en-US', options);
|
|
return formatedDate;
|
|
}
|
|
|
|
console.log(formatDate(new Date('2023-05-31'))); // => 'May 31, 2023'
|
|
console.log(formatDate(new Date('2024-01-01'))); // => 'January 1, 2024'
|
|
</script>
|
|
</body>
|
|
</html>
|