🐍

Python YYYY-MM-DD

Izhod: 2025-01-15
Hitra referenca
Niz formata
%Y-%m-%d
Izhod
2025-01-15

Oblikuj datum kot YYYY-MM-DD v Python

🐍 Python
from datetime import datetime date = datetime.now() formatted = date.strftime('%Y-%m-%d') print(formatted) # Output: 2025-12-31

Razčleni niz datuma

🐍 Python (Razčlenjevanje)
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:00

Kode formata datuma v Python

Koda Pomen Primer
%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

Drugi formati v Python

YYYY-MM-DD v drugih jezikih

Uradna dokumentacija

Za več informacij o oblikovanju datumov v Python si oglejte uradno dokumentacijo:

Dokumentacija datumov za Python →

Povezane strani