🐍
Python YYYY-MM-DD
Saida: 2025-01-15
Referencia Rapida
String de Formato
%Y-%m-%d
Saida
2025-01-15
Formatar data como YYYY-MM-DD em Python
🐍 Python
from datetime import datetime
date = datetime.now()
formatted = date.strftime('%Y-%m-%d')
print(formatted) # Output: 2025-12-31Analisar string de data
🐍 Python (Analise)
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 data Python
| Codigo | Significado | Exemplo |
|---|---|---|
| %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 |
Outros formatos em Python
YYYY-MM-DD em outras linguagens
Documentacao Oficial
Para mais informacoes sobre formatacao de datas em Python, consulte a documentacao oficial: