💛
JavaScript Date Format YYYY-MM-DD
Output: 2025-01-15
Quick Reference
Output
2025-01-15
Format Date as YYYY-MM-DD in JavaScript
💛 JavaScript
const date = new Date();
// Method 1: toISOString (recommended)
const formatted = date.toISOString().split('T')[0];
console.log(formatted); // Output: 2025-12-31
// Method 2: Manual formatting
const yyyy = date.getFullYear();
const mm = String(date.getMonth() + 1).padStart(2, '0');
const dd = String(date.getDate()).padStart(2, '0');
console.log(`${yyyy}-${mm}-${dd}`); // Output: 2025-12-31Other Formats in JavaScript
YYYY-MM-DD in Other Languages
Official Documentation
For more information about date formatting in JavaScript, see the official documentation: