Muunna DD/MM/YYYY YYYY-MM-muotoon

15/01/2025 → 2025-01

Pikamuunnin

2025-01

Miten Muunnetaan DD/MM/YYYY YYYY-MM-muotoon

Muuntaminen DD/MM/YYYY-muodosta YYYY-MM-muotoon sisältää päivämääräkomponenttien uudelleenjärjestelyn:

Muodosta
DD/MM/YYYY
15/01/2025
muotoon
YYYY-MM
2025-01
1

Tunnista Osat

DD/MM/YYYY-muodossa: Day-Month-Year format commonly used in Europe, Asia, and most of the world

2

Järjestä Uudelleen

Järjestä uudelleen vastaamaan YYYY-MM-muotoa: Year-month format following ISO 8601, ideal for file naming and sorting

3

Säädä Erotin

Vaihda erotin "/" muotoon "-" tarvittaessa.

Koodiesimerkit

JavaScript
// Muunna DD/MM/YYYY YYYY-MM-muotoon function convertDate(dateStr) { // Jäsennä DD/MM/YYYY const parts = dateStr.split('/'); const [day, month, year] = parts; // Muotoile YYYY-MM-muodossa return `${year}-${month}-${day}`; } console.log(convertDate('15/01/2025')); // 2025-01
Python
from datetime import datetime # Muunna DD/MM/YYYY YYYY-MM-muotoon date_str = '15/01/2025' date = datetime.strptime(date_str, '%d/%m/%Y') result = date.strftime('%Y-%m-%d') print(result) # 2025-01

Muut Muunnokset

Avaa Täysi Muunnin →

Liittyvät Sivut