I am new to Drupal. I want to display event date like,

"28/07/2016 | 02 PM to 04 PM"

Default date formats display date like,

"28/07/2016 - 02 PM to 28/07/2016 - 04 PM"

How can I create such custom display format?

  • This could be a duplicate of stackoverflow.com/questions/8375674/…\
    – ARUN
    Jul 28 '16 at 8:48
  • Do you mean you are using 2 date fields for saving the start and end time?
    – Jimmy Ko
    Jul 28 '16 at 9:34
  • yes @JimmyKo . I am using one field for date and 2 fields for start and end time respectively. I want it to be displayed it as One date value and two time values showing start and end time Jul 28 '16 at 10:09

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.

UPDATE: From following comment,

If you want optional End time, use Timefield module

Timefield is a Field API field for storing simple non-timezone time values, with an optional end time, utilizing a simple JQuery timepicker widget for input.

  • Thank you for response @Arun. I don't want date to be displayed like Y-M-d or anything like that. I want to display date in the form of d-M-Y | start time - end time for example "28/07/2016 | 03 PM to 05 PM". Creating a new date format allows me to change order of date, month and year. How can I display time slots without repetition of date Jul 28 '16 at 9:05
  • Did you try this module drupal.org/project/timefield. This module will allow you to define time with End time.
    – ARUN
    Jul 28 '16 at 9:09
  • Issue got fixed?
    – ARUN
    Jul 28 '16 at 10:54
  • Yes @Arun. I used one field for date and this time field module took care of time duration. So, I got what I was looking for. Thank you :) Jul 28 '16 at 11:58

Using hook_date_formats() you can create date format


function app_common_date_formats() {
  $formats = array();
  $formats[] = array(
    'type'    => 'test_custom_date_format',
    'format'  => 'd-M-Y',
    'locales' => array(), );
  foreach ($formats as $format) {
    variable_set('date_format_' . $format['type'], $format['format']);
return $formats;


  • Hi @Fawwad, Thank you for response. I got your point, this code will create a date format in the form of d-M-Y.How can I get display format like "d-M-Y | 02 PM to 04 PM"? Jul 28 '16 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.