开发者

drupal7 change format of comment's $created

开发者 https://www.devze.com 2023-04-05 00:38 出处:网络
I have been trying for some time now to reformat the date that appears below the avatar when a comment is made to a blog post.

I have been trying for some time now to reformat the date that appears below the avatar when a comment is made to a blog post.

I have 开发者_开发技巧found no way of doing it through any settings, so I have moved over to the template files. Changing the date format of the original blog post was easy, but with comments, no variable holding the date in raw (unix) format is passed in to the template, so I can't reformat and extract the pieces of the date that I want.

The Zen theme help note says:

* - $created: Formatted date and time for when the comment was created.

I would like to reformat this from Tue, 2011-09-13 11:57

Into two separate variables, 13 Sep, 2011 11:57

any idéas? Thanks


In your template file you should have access to the $node variable so you can do something like this:

echo date('j M, Y H:i', $node->created);

See the PHP date page for information on the format string used above.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号