Date and Time Formats in Drupal

drupal date format

One 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:
  • 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:

Author

  • Steve Burge

    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.

0 0 votes
Article Rating
Subscribe
Notify of
1 Comment
Oldest
Newest
Inline Feedbacks
View all comments
David Martin
David Martin
5 years ago

If using Drupal 8 the Date module has been moved into the core but not all functionality has been added so you may just be left in lurch by adopting D8 too soon.

1
0
Would love your thoughts, please comment.x
()
x