Community & Support

Modifying date in comments - need help

I'm trying to modify the date in comments - a simple M j, Y. I've been able to do this in the node itself by using the template.php code from the blue_zinfandel theme:

function _phptemplate_variables($hook, $vars) {
  switch ($hook) {
    case 'node':
      $node = $vars['node'];
// Variables for the calendar date display.
      $vars['month'] = date('M', $node->created);
      $vars['day'] = date('j', $node->created);
...

But I'm trying to do something similar with the comment date. But so far all I've been able to print is Dec 31, 1969 or nothing at all.

switch ($hook)   {
    case 'comment':
      $comment = $vars['comment'];               
                           
      $vars['monthcomment'] = date('M', $comment->created);
      $vars['daycomment'] = date('j', $comment->created);
...

Any idea on what I should be using? Or am I going about this all wrong?

~silverwing

Comments

subscribe...

subscribe...

http://basicmagic.net
drupal samurai for hire
buffalo, new york usa

modify date in comments

hi silverwing and thanks-

this is the custom code i use in my comment.tpl.php...

<?php print date('n/j/y', $comment->timestamp); ?> at <?php print date('g:ia', $comment->timestamp); ?>

sample output of this code:

11/8/07 at 11:59pm

and you can also see it live and in action at this site:
http://www.wallstreetoasis.com

hope it may help you...
and no changes to template.php are required with this method.

thanks-
vincent, in buffalo

http://www.basicmagic.net
Websites That Work - Open Source Power for Your Enterprise

http://basicmagic.net
drupal samurai for hire
buffalo, new york usa

thank you!

That was just the fix I needed!

I spent some time looking at other date arrays in other themes, and my eyes just began to glaze over. And your code is actually quite simpl!

Again, thank you!

~silverwing

___________________________
MisguidedThoughts | tvTonight

________________________________
MisguidedThoughts

nobody click here