How to Add the Current Date to a View in Drupal 7

How to Add the Current Date to a View in Drupal 7

Header
FFW Marketing
Thought byFFW Marketing
Website Administrator
April 03, 2014

Today, someone in IRC asked how to add the current date to a View they were working on. Seemed simple enough, and I offered to help, thinking it was just a matter of sticking a token in the View header. And it was...sort of. Incredibly, Google searches turned up only code-based solutions. Overkill. Here's a UI-based approach.

To add the current date to the top of a View, follow these steps:

  1. Install and enable the Token Filter module.
  2. Go to Configuration > Content authoring > Text formats.
  3. Choose a text format to edit, and under Enabled filters check the box for Replace tokens.
Drupal 7 Add the Current Date to a View

 

  1. In another tab, pull up the List of tokens for Drupal 7.
  2. Go to your View.
  3. Add a Header, using the Global: Text area option. (You can find the Header in the center column of the full Views UI.)
  4. Paste the token for your preferred date format into the big text field, and make sure to choose the Text format you enabled token replacement for.
Drupal 7 Configure Header with Date Token

That should do it! Apply your header to the appropriate display(s), and you should see the date in your preview.

Happy Drupaling!

Topics:
drupal 7

Read next:

Blog
Orange Google Analytics logo with arrow pointing to blue Google Tag Manager logo.

A why-to and how-to guide from FFW on getting the most out of the measurement tools that integrate with your website.

Blog
FFW Blog - illustration

Creating Custom Search Pages with Search404 and Apache Solr Search

Blog
dummy image

How to Configure CyberSource Secure Acceptance Web/Mobile in Drupal 7

Blog
Drupal 7 and Ajax

Views Taxonomy Links as Exposed Filter with Ajax enabled for Drupal 7