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

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

FFW Marketing
VonFFW Marketing
April 03, 2014
Laptop with a bullseye on the screen

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!