🐍

Python YYYY-MM-DD

Sortie: 2025-01-15
Reference Rapide
Chaine de Format
%Y-%m-%d
Sortie
2025-01-15

Formater la date en YYYY-MM-DD avec Python

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

Analyser une chaine de date

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

Codes de format de date Python

Code Signification Exemple
%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

Autres formats en Python

YYYY-MM-DD dans autres langages

Documentation Officielle

Pour plus informations sur le formatage des dates en Python, consultez la documentation officielle :

Documentation des dates Python →

Pages Associees