Skip to content

Instantly share code, notes, and snippets.

@chadsten
Created July 16, 2013 19:57
Show Gist options
  • Select an option

  • Save chadsten/6012106 to your computer and use it in GitHub Desktop.

Select an option

Save chadsten/6012106 to your computer and use it in GitHub Desktop.
<?php
list($start, $end) = explode(' to ', $items[0]['#markup']);
$time_format = 'g:i A';
$date_format = 'F jS, Y';
$start = strtotime($start);
$start_date = date($date_format, $start);
$start_time = date($time_format, $start);
if ($end) {
$end = strtotime($end);
$end_date = date($date_format, $end);
$end_time = date($time_format, $end);
}
?>
<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php if (!$label_hidden): ?>
<div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
<?php endif; ?>
<div class="altered field-items"<?php print $content_attributes; ?>>
<div class="date-time-wrapper date">
<span class="date-time date from"><?= $start_date; ?></span>
<?php if ($end_date && $start_date != $end_date) { ?> <span class="separator"> - </span><span class="date-time date to"><?= $end_date; ?></span> <?php } ?>
</div>
<div class="date-time-wrapper time">
<span class="date-time time from"><?= $start_time; ?></span>
<?php if ($end_time && $start_date != $end_date && $start_time != $end_time) { ?><span class="separator"> - </span><span class="date-time time to"><?= $end_time; ?></span> <?php } ?>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment