[PHP]date関数で日付のフォーマットを変更する
2019年7月1日
「YYYY-MM-DD」の書式を「YYYY年MM月DD日」に変換する。
・サンプルコード
$date = '2019-05-10 00:00:00'; echo date('Y年m月d日', strtotime($date)); echo "<br>"; $date = '2019-05-10'; echo date('Y年m月d日', strtotime($date)); echo "<br>"; $date = '2019-05'; echo date('Y年m月d日', strtotime($date)); echo "<br>";
・実行結果

日を省略した場合は1日が適用される。