I-convert ang DD/MM/YYYY sa YYYY-MM-DD
15/01/2025 → 2025-01-15
Mabilis na Converter
→
2025-01-15
Paano I-convert ang DD/MM/YYYY sa YYYY-MM-DD
Ang pag-convert mula DD/MM/YYYY sa YYYY-MM-DD ay kinabibilangan ng muling pag-aayos ng mga bahagi ng petsa:
Mula sa
DD/MM/YYYY
15/01/2025
sa
YYYY-MM-DD
2025-01-15
1
Tukuyin ang mga Bahagi
Sa DD/MM/YYYY: Day-Month-Year format commonly used in Europe, Asia, and most of the world
2
Ayusin Muli
Muling ayusin upang tumugma sa format na YYYY-MM-DD: ISO 8601 standard format, ideal for sorting and international use
3
Ayusin ang Separator
Baguhin ang separator mula "/" sa "-" kung kinakailangan.
Mga Halimbawa ng Code
JavaScript
// I-convert ang DD/MM/YYYY sa YYYY-MM-DD
function convertDate(dateStr) {
// I-parse ang DD/MM/YYYY
const parts = dateStr.split('/');
const [day, month, year] = parts;
// I-format bilang YYYY-MM-DD
return `${year}-${month}-${day}`;
}
console.log(convertDate('15/01/2025')); // 2025-01-15
Python
from datetime import datetime
# I-convert ang DD/MM/YYYY sa YYYY-MM-DD
date_str = '15/01/2025'
date = datetime.strptime(date_str, '%d/%m/%Y')
result = date.strftime('%Y-%m-%d')
print(result) # 2025-01-15