Konverto DD/MM/YYYY në MM/YYYY
15/01/2025 → 01/2025
Konvertues i Shpejtë
→
01/2025
Si të Konvertosh DD/MM/YYYY në MM/YYYY
Konvertimi nga DD/MM/YYYY në MM/YYYY përfshin riorganizimin e komponentëve të datës:
Nga
DD/MM/YYYY
15/01/2025
në
MM/YYYY
01/2025
1
Identifiko Pjesët
Në DD/MM/YYYY: Day-Month-Year format commonly used in Europe, Asia, and most of the world
2
Riorganizo
Riorganizo për të përputhur formatin MM/YYYY: Month-year format commonly used for credit cards, expiration dates, and monthly reports
3
Rregullo Ndarësin
Ndrysho ndarësin nga "/" në "/" nëse nevojitet.
Shembuj Kodi
JavaScript
// Konverto DD/MM/YYYY në MM/YYYY
function convertDate(dateStr) {
// Analizo DD/MM/YYYY
const parts = dateStr.split('/');
const [day, month, year] = parts;
// Formato si MM/YYYY
return `${year}-${month}-${day}`;
}
console.log(convertDate('15/01/2025')); // 01/2025
Python
from datetime import datetime
# Konverto DD/MM/YYYY në MM/YYYY
date_str = '15/01/2025'
date = datetime.strptime(date_str, '%d/%m/%Y')
result = date.strftime('%Y-%m-%d')
print(result) # 01/2025