Hi, I was wondering if it is possible to have some option regarding how the start date and end date is displayed. I've been using module for our events. And I notice that the start date and end date are displayed separately, which might be not as concise as the format like January 1-2, 2012. There are surely many cases when it is better to display the dates separately, so what I'm suggesting is just to make it as an option.

Thank you!

Comments

chucksimply’s picture

Are you referring to the formatting of the start and end date? Because I think this would solve the problem. If the start and end date could each be formatted differently, you could create a wider variety of simpler date start-end combinations. For instance in the above case... Start Date = January 1, End Date = 2, 2012. The combination would be January 1-2, 2012. This is doable in Views, but not in the standard date field. Would love to see it.

DrupalDan’s picture

Hi ChuckSimply, thanks for your response. Yes, I'm looking for an easy way to make start date and end date shown as "January 1-2, 2012" but don't know how to do it. Can you give me some more information?

Thanks

Anonymous’s picture

I have a similar problem, but my end date is not mandatory. If you always have an end date, you can

1. Add a Start Date to the view, format according and exclude from View
2. Add a End Date to the view, format according and exclude from View
3. Add a field which combines the two in a Rewrite rule.

dotmundo’s picture

What if the date goes from Jan 30 to Feb 1? It might be best to do this in the field template using PHP.

JKingsnorth’s picture

Title: Format of start and end date » Allow different formats for start and end date
Issue summary: View changes
jphelan’s picture

This is probably not the best way to do it but in views create a template file for your date field and output your date field as "Plain" and "Both Start and End Dates". Then in your template file put the code below. This accounts for dates the span months or years. Format the date output to your liking date().

if(!empty($output)) {
  $dates = explode(" to ", $output);
  $start_time = strtotime($dates[0]);
  if(!empty($dates[1])) {
    $end_time = strtotime($dates[1]);
  } else {
    $end_time = $start_time;
  }
  if($start_time == $end_time) {
    print date('F j, Y', $start_time);
  } elseif ((date('Y', $start_time) != date('Y', $end_time))) {
    print date('F j, Y ', $start_time) . ' - ' . date('F j, Y', $end_time);
  } elseif ((date('F', $start_time) != date('F', $end_time))) {
    print date('F j - ', $start_time) . date('F j, Y', $end_time);
  } else {
    print date('F j - ', $start_time) . date('j, Y', $end_time);
  }
}
localnetwork’s picture