Convert MM/DD/YYYY to YYYY-MM

01/15/2025 → 2025-01

Quick Converter

2025-01

How to Convert MM/DD/YYYY to YYYY-MM

Converting from MM/DD/YYYY to YYYY-MM involves rearranging the date components:

From
MM/DD/YYYY
01/15/2025
To
YYYY-MM
2025-01
1

Identify the Parts

In MM/DD/YYYY: Month-Day-Year format primarily used in the United States

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 MM/DD/YYYY to YYYY-MM function convertDate(dateStr) { // Parse MM/DD/YYYY const parts = dateStr.split('/'); const [month, day, year] = parts; // Format as YYYY-MM return `${year}-${month}-${day}`; } console.log(convertDate('01/15/2025')); // 2025-01
Python
from datetime import datetime # Convert MM/DD/YYYY to YYYY-MM date_str = '01/15/2025' date = datetime.strptime(date_str, '%m/%d/%Y') result = date.strftime('%Y-%m-%d') print(result) # 2025-01

Other Conversions

Open Full Converter →

Related Pages