22

How do you add a custom Drupal date format. I want to display the date without hours and minutes, but the options don't include it.

vfclists
  • 19,193
  • 21
  • 73
  • 92
  • Just adding to the selected answer, I've created a video tutorial on this that contain a bit more information for anyone who is interested: http://gleamly.com/article/drupal-date-api-creating-custom-date-format – Joshua Kissoon Jul 21 '15 at 13:14

2 Answers2

42

Do the following:

  1. Administration » Configuration » Regional and language » Date and Time

  2. There you will see a tab for format.

  3. Create a new format string "Y-M-d".

  4. Make this as your default for all date fields and you won't see the seconds any more.

  5. You don't need the date module for basic formatting.

Cheers, Vishal

Below is the image so that you know where it is.

Drupal Date and time "Formats" tab

maciek
  • 3,198
  • 2
  • 26
  • 33
Vishal Khialani
  • 2,557
  • 6
  • 38
  • 49
  • 1
    Good answer. I assumed that was part of the date module. +1 to you. – SpaceBeers Dec 04 '11 at 14:56
  • There is no tab for format in mine. The format is a drop down select box that doesn't allow typing. They are all preset. This is the breadcrumb to that page, in case you are referring to something different Home » Administration » Configuration » Regional and language – vfclists Dec 04 '11 at 15:40
  • 1
    I have added a screen shot for you to find it – Vishal Khialani Dec 04 '11 at 15:46
  • is there a way to add a custom date format using the date module's from beginning and end times in hours and minutes? for example: d.m.Y, (from:) hh:mm (to) hh:mm -- (where hh = hours and mm == minutes) – Alex Mar 21 '13 at 11:50
  • @Alex unfortunately there is none. – maciek Oct 06 '15 at 10:25
4

You will see a button Add format in this path admin/config/regional/date-time/formats

Then, type your format there. This will help you: http://php.net/manual/en/function.date.php

After adding your format, you can choose in the tab Types

Oops. I had this tab open in my browser for long time and didn't see the other answer.

corbacho
  • 8,762
  • 1
  • 26
  • 23