🐍
Python YYYY-MM-DD
出力: 2025-01-15
クイックリファレンス
フォーマット文字列
%Y-%m-%d
出力
2025-01-15
PythonでYYYY-MM-DD形式に日付をフォーマット
🐍 Python
from datetime import datetime
date = datetime.now()
formatted = date.strftime('%Y-%m-%d')
print(formatted) # Output: 2025-12-31日付文字列の解析
🐍 Python (解析)
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:00Python日付フォーマットコード
| コード | 意味 | 例 |
|---|---|---|
| %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 |
Pythonの他のフォーマット
他の言語でのYYYY-MM-DD
公式ドキュメント
Pythonでの日付フォーマットの詳細については、公式ドキュメントをご覧ください: