Convert DD/MM/YYYY to YYYY-MM
15/01/2025 → 2025-01
Quick Converter
→
2025-01
How to Convert DD/MM/YYYY to YYYY-MM
Converting from DD/MM/YYYY to YYYY-MM involves rearranging the date components:
From
DD/MM/YYYY
15/01/2025
To
YYYY-MM
2025-01
1
Identify the Parts
In DD/MM/YYYY: Day-Month-Year format commonly used in Europe, Asia, and most of the world
2
Rearrange
Reorder to match YYYY-MM format: Year-month format following ISO 8601, ideal for file naming and sorting
3
Adjust Separator
Change the separator from "/" to "-" if needed.
Code Examples
JavaScript
// Convert DD/MM/YYYY to YYYY-MM
function convertDate(dateStr) {
// Parse DD/MM/YYYY
const parts = dateStr.split('/');
const [day, month, year] = parts;
// Format as YYYY-MM
return `${year}-${month}-${day}`;
}
console.log(convertDate('15/01/2025')); // 2025-01
Python
from datetime import datetime
# Convert DD/MM/YYYY to YYYY-MM
date_str = '15/01/2025'
date = datetime.strptime(date_str, '%d/%m/%Y')
result = date.strftime('%Y-%m-%d')
print(result) # 2025-01