help to better help you:
Please: add always Joomla / JEM version and details to your posts, so we can try to reproduce your issue!
[SOLVED] Times in 12-Hour vs. 24-Hour on Event Edit
[SOLVED] Times in 12-Hour vs. 24-Hour on Event Edit
8 years 6 months ago - 8 years 6 months ago
I have the times transferring on the front end to 12-Hour format, but would like to know how to set the times on the backend to 12 hour for those adding events. What page within the script do I modify to do this?
Joomla 3.5.1
JEM 2.1.6 stable (with Customization)
PHP: 5.4.45
JEM 2.1.6 stable (with Customization)
PHP: 5.4.45
Last edit: 8 years 6 months ago by rstarkey. Reason: Solved
Please Log in or Create an account to join the conversation.
Re: Times in 12-Hour vs. 24-Hour on Event Edit
8 years 6 months ago - 8 years 6 months ago
Hi rstarkey,
your question surprises me. Normally you only need to change the Time Format string on JEM Settings (Basic or Global tab, don't have a backend yet). This will change the output on all views of JEM component, backend and frontend.
The modules may have their own setting but if it's empty component's setting is used.
your question surprises me. Normally you only need to change the Time Format string on JEM Settings (Basic or Global tab, don't have a backend yet). This will change the output on all views of JEM component, backend and frontend.
The modules may have their own setting but if it's empty component's setting is used.
Last edit: 8 years 6 months ago by Hoffi.
Please Log in or Create an account to join the conversation.
Re: Times in 12-Hour vs. 24-Hour on Event Edit
8 years 6 months ago - 8 years 6 months ago
Hi Hoffi,
It changes everything on the front end that the customer sees, however it does not change the add event times to 12-hour.
Robert
It changes everything on the front end that the customer sees, however it does not change the add event times to 12-hour.
Robert
Joomla 3.5.1
JEM 2.1.6 stable (with Customization)
PHP: 5.4.45
JEM 2.1.6 stable (with Customization)
PHP: 5.4.45
Last edit: 8 years 6 months ago by rstarkey.
Please Log in or Create an account to join the conversation.
Re: Times in 12-Hour vs. 24-Hour on Event Edit
8 years 6 months ago
Ah, now I understand. It's not shown time, it's time input using the two dropdown fields. That's also on frontend on Edit event view.
The function to fill the fields is buildtimeselect() located in components/com_jem/helpers/help.php around line 623.
Within the "$timelist[] = ..." lines the first $value must be unchanged but the second is the text shown. So there you can map values from 0..23 to '12 am'..'11 pm' if $max == 23 (because the function is also used for the minutes). The simplest way would be an array
The function to fill the fields is buildtimeselect() located in components/com_jem/helpers/help.php around line 623.
Within the "$timelist[] = ..." lines the first $value must be unchanged but the second is the text shown. So there you can map values from 0..23 to '12 am'..'11 pm' if $max == 23 (because the function is also used for the minutes). The simplest way would be an array
Please Log in or Create an account to join the conversation.
Re: Times in 12-Hour vs. 24-Hour on Event Edit
8 years 6 months ago
I found where you are talking about...
But not sure what to change, or where. Could you give me a copy and replace set of code that I could use to correct this?
Code:
static function buildtimeselect($max, $name, $selected, $class = array('class'=>'inputbox'))
{
$timelist = array();
$timelist[0] = JHtml::_('select.option', '', '');
foreach(range(0, $max) as $value) {
if($value >= 10) {
$timelist[] = JHtml::_('select.option', $value, $value);
} else {
$timelist[] = JHtml::_('select.option', '0'.$value, '0'.$value);
}
}
return JHtml::_('select.genericlist', $timelist, $name, $class, 'value', 'text', $selected);
}
But not sure what to change, or where. Could you give me a copy and replace set of code that I could use to correct this?
Joomla 3.5.1
JEM 2.1.6 stable (with Customization)
PHP: 5.4.45
JEM 2.1.6 stable (with Customization)
PHP: 5.4.45
Please Log in or Create an account to join the conversation.
Re: Times in 12-Hour vs. 24-Hour on Event Edit
8 years 6 months ago
Sure, you could try following:
This function now checks Format Time setting to find out if you like 12 or 24 hours format and then shows hours as "00".."23" or "12 AM".."11 PM". Because it respects user's decision I think I will put this code into next JEM version.
Code:
static function buildtimeselect($max, $name, $selected, $class = array('class'=>'inputbox'))
{
$timelist = array();
$timelist[0] = JHtml::_('select.option', '', '');
if ($max == 23) {
// does user prefer 12 or 24 hours format?
$jemreg = JemConfig::getInstance()->toRegistry();
$timeformat = $jemreg->get('formattime');
$format = preg_match('/%[Ir]/', $timeformat) ? '%I %p' : '%H';
}
foreach (range(0, $max) as $value) {
if ($value < 10) {
$value = '0'.$value;
}
$timelist[] = JHtml::_('select.option', $value, ($max == 23 ? strftime($format, strtotime("$value:00:00")) : $value));
}
return JHtml::_('select.genericlist', $timelist, $name, $class, 'value', 'text', $selected);
}
This function now checks Format Time setting to find out if you like 12 or 24 hours format and then shows hours as "00".."23" or "12 AM".."11 PM". Because it respects user's decision I think I will put this code into next JEM version.
The following user(s) said Thank You: jojo12
Please Log in or Create an account to join the conversation.
Time to create page: 0.571 seconds