Using PHP to Change Drupal Date Display

Once you install your Drupal site, you will need to perform some basic configuration. One of the first things to do is to set the date and time. By default, Drupal provides a pretty long format to display the date on your site.

You can update this by using PHP. First you need to go to the Drupal date and time admin page. To get to that admin page, type the following into your web browser: http://mysite.com/admin/settings/date-time.

This example assumes you have clean URL's enabled, otherwise you would type: http://mysite.com/?q=admin/settings/date-time. The page should look something like the image below:

Drupal Date and Time Admin Screen
Drupal Date and Time Admin Screen

You can configure the time as you like. Next, scroll down to the formatting section. Under "short date format" text, select the drop down menu and pick "custom format".

Drupal Custom Date
Drupal Custom Date

From here, a text field will appear where you define your custom date using the PHP date function. You can see I typed M d, Y. Notice Drupal shows an example of how the date will appear in the text under the text field. Rinse and repeat for the medium and long date format.

Drupal Custom Date
Drupal Custom Date

Resources

About Ishmael


I am a web developer. This is my portfolio. Find out more about me. Contact me about services I can provide.