🐍
Python YYYY-MM-DD
Salida: 2025-01-15
Referencia Rapida
Cadena de Formato
%Y-%m-%d
Salida
2025-01-15
Formatear fecha como YYYY-MM-DD en Python
🐍 Python
from datetime import datetime
date = datetime.now()
formatted = date.strftime('%Y-%m-%d')
print(formatted) # Output: 2025-12-31Parsear cadena de fecha
🐍 Python (Parseo)
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:00Codigos de formato de fecha de Python
| Codigo | Significado | Ejemplo |
|---|---|---|
| %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 |
Otros formatos en Python
YYYY-MM-DD en otros lenguajes
Documentacion Oficial
Para mas informacion sobre el formateo de fechas en Python, consulta la documentacion oficial: