Muunna MM/DD/YYYY DD/MM/YYYY-muotoon
01/15/2025 → 15/01/2025
Pikamuunnin
→
15/01/2025
Miten Muunnetaan MM/DD/YYYY DD/MM/YYYY-muotoon
Muuntaminen MM/DD/YYYY-muodosta DD/MM/YYYY-muotoon sisältää päivämääräkomponenttien uudelleenjärjestelyn:
Muodosta
MM/DD/YYYY
01/15/2025
muotoon
DD/MM/YYYY
15/01/2025
1
Tunnista Osat
MM/DD/YYYY-muodossa: Month-Day-Year format primarily used in the United States
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/DD/YYYY DD/MM/YYYY-muotoon
function convertDate(dateStr) {
// Jäsennä MM/DD/YYYY
const parts = dateStr.split('/');
const [month, day, year] = parts;
// Muotoile DD/MM/YYYY-muodossa
return `${day}/${month}/${year}`;
}
console.log(convertDate('01/15/2025')); // 15/01/2025
Python
from datetime import datetime
# Muunna MM/DD/YYYY DD/MM/YYYY-muotoon
date_str = '01/15/2025'
date = datetime.strptime(date_str, '%m/%d/%Y')
result = date.strftime('%d/%m/%Y')
print(result) # 15/01/2025