How can I change the date format in my comments?

Right now it looks like this:

Sat, 09/01/2012 - 12:00

I want it to look like this:

Saturday, September 1, 2012

I was able to achieve this in page.tpl.php in a section where I just display the date, but have no idea where to do this so it works for my comments too.

3 Answers 3


If you want to do it sitewide, you can edit the definitions at admin/config/regional/date-time/formats

You can also add your own formats there, and then use them in format_date() similar to what @Epok outlined.

  • This is the correct answer. There is no need to change the theme, when there is a global setting.
    – apaderno
    Sep 2, 2012 at 18:03

When you watch your comment.tpl.php you see that you can override some variables with template_preprocess_comment()

I don't know if it's the best way but it works fine for me. You have to put this function in template.php

function mytheme_preprocess_comment(&$variables){
  $variables['created'] = date('l, F d, Y', $variables['elements']['#comment']->created);
  $variables['changed'] = date('l, F d, Y', $variables['elements']['#comment']->created);

comments date There is a post about this on Drupal.org


You can also use format_date() function: format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)

Please note UNIX timestamp is timezone blind.

function YOURTHEME_preprocess_comment(&$variables) {      
  $variables['created'] = format_date($variables['elements']['#comment']->created, 'custom', 'l, j F Y h:i A');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.