🐍
Python YYYY-MM-DD
Izlaz: 2025-01-15
Brza referenca
Niz formata
%Y-%m-%d
Izlaz
2025-01-15
Formatiraj datum kao YYYY-MM-DD u Python
🐍 Python
from datetime import datetime
date = datetime.now()
formatted = date.strftime('%Y-%m-%d')
print(formatted) # Output: 2025-12-31Parsiraj niz datuma
🐍 Python (Parsiranje)
from datetime import datetime
date_string = '2025-12-31'
date = datetime.strptime(date_string, '%Y-%m-%d')
print(date) # Output: 2025-12-31 00:00:00Kodovi formata datuma u Python
| Kod | Značenje | Primjer |
|---|---|---|
| %d | Day of month (01-31) | 31 |
| %m | Month (01-12) | 12 |
| %Y | Year with century | 2025 |
| %y | Year without century (00-99) | 25 |
| %b | Abbreviated month name | Dec |
| %B | Full month name | December |
| %a | Abbreviated weekday | Wed |
| %A | Full weekday name | Wednesday |
Ostali formati u Python
YYYY-MM-DD u drugim jezicima
Službena dokumentacija
Za više informacija o formatiranju datuma u Python, pogledajte službenu dokumentaciju: