WordPressユーザーのbaserCMS覚え書き


記事の投稿日を出力する

WordPress

the_time(), the_date()

テンプレートタグ/the time - WordPress Codex 日本語版
テンプレートタグ/the date - WordPress Codex 日本語版

baserCMS(3系)

$this->Blog->postDate( $post , [$format] )

[postDate] 記事の登録日を出力する|baserCMS 3系関数リファレンス

メモ

baserCMSでは、ブログの記事編集画面にある「投稿日」で設定した日付が出力されます。第2引数の $format はPHPの date() 関数に準じているので、date() のリファレンスを参考にしながら任意のフォーマットで投稿日を表示させることが可能です。

ちなみに postDate() では記事作成日の出力はできないのでご注意ください。

記事作成日を出力するコード例

<?php 
if (!empty($post['BlogPost']['created'])) {
    echo $this->BcTime->format('Y.n.j', $post['BlogPost']['created']);
}
?>

'created' を 'modified' にすると、記事の最終更新日を出力できます。