• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 103
  • Last Modified:

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

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:  

   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.

1 Solution
Aaron FeledyDrupal Developer and ConsultantCommented:
Using the php filter, you can do this:
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.
scottlumAuthor Commented:
Excellent--exactly what I'm looking for--thanks!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now