Muunna MM/YYYY DD/MM/YYYY-muotoon
01/2025 → 15/01/2025
Pikamuunnin
→
15/01/2025
Miten Muunnetaan MM/YYYY DD/MM/YYYY-muotoon
Muuntaminen MM/YYYY-muodosta DD/MM/YYYY-muotoon sisältää päivämääräkomponenttien uudelleenjärjestelyn:
Muodosta
MM/YYYY
01/2025
muotoon
DD/MM/YYYY
15/01/2025
1
Tunnista Osat
MM/YYYY-muodossa: Month-year format commonly used for credit cards, expiration dates, and monthly reports
2
Järjestä Uudelleen
Järjestä uudelleen vastaamaan DD/MM/YYYY-muotoa: Day-Month-Year format commonly used in Europe, Asia, and most of the world
3
Säädä Erotin
Vaihda erotin "/" muotoon "/" tarvittaessa.
Koodiesimerkit
JavaScript
// Muunna MM/YYYY DD/MM/YYYY-muotoon
function convertDate(dateStr) {
// Jäsennä MM/YYYY
const parts = dateStr.split('/');
const [year, month, day] = parts;
// Muotoile DD/MM/YYYY-muodossa
return `${day}/${month}/${year}`;
}
console.log(convertDate('01/2025')); // 15/01/2025
Python
from datetime import datetime
# Muunna MM/YYYY DD/MM/YYYY-muotoon
date_str = '01/2025'
date = datetime.strptime(date_str, '%Y-%m-%d')
result = date.strftime('%d/%m/%Y')
print(result) # 15/01/2025