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
Solved

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

Posted on 2015-01-23
2
79 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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Configure a website to disconnect/timeout after 30 minutes 1 541
PHP Session ID 5 101
how to extract window origin in spring 2 74
Joomla Website Malfunction 9 127
      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
Introduction (All good things must come to an end (http://en.wikipedia.org/wiki/All_Good_Things...))The original MySQL API (http://php.net/manual/en/book.mysql.php) has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all current…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
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.

829 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