Solved

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

Posted on 2015-01-23
2
82 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

739 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