🐍

Python YYYY-MM-DD

Ieșire: 2025-01-15
Referință Rapidă
Șir de Format
%Y-%m-%d
Ieșire
2025-01-15

Formatarea datei ca YYYY-MM-DD în Python

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

Parsarea șirului de dată

🐍 Python (Parsare)
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

Coduri de format dată Python

Cod Semnificație Exemplu
%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

Alte formate în Python

YYYY-MM-DD în alte limbaje

Documentație Oficială

Pentru mai multe informații despre formatarea datelor în Python, vezi documentația oficială:

Documentația datelor Python →

Pagini Conexe