Solved

Changing date format in a drupal template

Posted on 2014-02-28
3
393 Views
Last Modified: 2014-03-10
Hello
I am trying to customize comment.tpl.php (not the core template of course)

I would like the date to render as "time ago" I've seen this as an option in views, but I have no clue how to get the same thing in a template.

here is what I have
<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  <?php print $picture ?>
  <div class="content"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['links']);
     print ($id); 
	 print ".&nbsp;&nbsp;";
	 print ($author);
	 print "&nbsp;";
      print strip_tags (render($content));
    ?>
    <br>
    <?php print ($created); ?>
  </div>

</div>

Open in new window


What do I need to do?
0
Comment
Question by:itkadmin
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39895715
See Practical Application #3 in this article.  It gives a function that you can easilytailor for your needs.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
0
 
LVL 2

Author Closing Comment

by:itkadmin
ID: 39917482
thanks
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39917503
Thanks for the points and best of luck with your project! ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now