Events Manager Time Input Fix

May 29th, 2010 | No Comments | Posted in Hacks & Mods, Wordpress

Odd bug: On a WordPressMU install the time picker only allows 24-hour input. Tracked it down to the file dbem_events.php. Starting around line 1203 you’ll find <code>
function dbem_event_form($event, $title, $element) </code>

A bit further down it uses WP’s built in get_locate() function to figure out where you are and set the format to 12 / 24 accordingly. For now I hacked it by just going to line 1826 <code> 
// Check if the locale is there and loads it
$locale_code = substr ( get_locale (), 0, 2 );
$show24Hours = ‘true’;
</code> and changing the $show24Hours to “false”.

Probably just a difference in WordPressMU since it works fine in single installs. My guess without looking further into it is that since WPMU allows for multiple blogs there is no standard locale — you could have blogs from various parts of the world all created within one install of MU.

I’ll get around to making 12 hour / 24 hour a settings option at some point if anyone else needs it.

**Also changed the following starting at line 1132:

<code>

  <?php
   echo substr ( $event ['event_start_time'], 0, 5 ) . ” – ” . substr ( $event ['event_end_time'], 0, 5 );
   ?>

</code>

to

<code> <?php
   echo date(‘g:i a’,strtotime($event ['event_start_time'] )). ” – ” . date(‘g:i a’,strtotime($event ['event_end_time']));
   ?></code>

So that the start and end times would show up in 12 hour format in the event list in the admin section.

Leave a Reply