Solved

Using php in body to display modified date of particular web page for Drupal 7.33

Posted on 2015-01-23
2
86 Views
Last Modified: 2015-01-23
I am a user of a Drupal 7 system that was given the permissions to create and publish new web pages for the site.

I would like to know if there is an easy way to display the last modified date on the web page using php.

I found this snippet, but it only displays the current date:  

<?php
   echo date('m/d/Y');
?>

I need to display the last modified date only on some selected pages--not all pages on the web site, so I do not want to change the template (I don't have access to the templates or any of the theme files or other system files.

Thanks!
0
Comment
Question by:scottlum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
Arrow_1 earned 500 total points
ID: 40567644
Using the php filter, you can do this:
<?php
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $node = node_load(arg(1));
  $date = date('m/d/Y', $node->changed);
  print $date;
}
?>

Open in new window


It checks the path to be sure it's a node, then loads the information about the node. It then formats the "changed" date and prints it.
0
 

Author Closing Comment

by:scottlum
ID: 40567749
Excellent--exactly what I'm looking for--thanks!!
0

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

626 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