Skip to main content

April 3, 2014

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

Thought by FFW,

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.

FFW Drual Developers: Replace Tokens

  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.
FFW Drupal Development: Header Token


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

Happy Drupaling!