| Drupal

drupal date formatOne of our members had this question for us:

"I'm using the Date module and I would like it to display morning as AM and evening as PM. At the moment it shows 15:00, but I'd like it to show 3 PM".

In this tutorial, we'll answer that question and show you how to set up Date and Time formats in Drupal.

  • Install the Date module.
  • Go to Structure > Content type > Manage fields.
  • Create a Date field.
  • Click the Manage Display tab.
  • Click the cog next to your Date field and you'll see the 3 default formats:
Date and Time Formats in Drupal
  • Go to Configuration > Date and Time and you'll see those 3 formats:
  • Click the Formats tab.
  • Click Add format.
  • You'll now see and empty box. Click the PHP manual link:
  • You'll be taken to PHP.net with a list of ways that PHP can show dates.
  • Find the data formats that you want and paste them into your Drupal site. For example, "j F, G A" will show as "30 December, 1 PM". On the right hand side, Drupal will give you a live preview of your format.
  • Click Add format.
  • Click Types.
  • Click Add date type.
  • Enter a name for your new Date type.
  • Choose the Date format:
  • Click Add date type. You'll now see your new format:
  • Go to Structure > Content types > Manage Display.
  • Choose your new date and time format:

About the author

Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.