Below is my calendar field in the form
<field name="job_next_run_date_time"
type="calendar"
label="JSCH_JOBV_NEXT_DATE_TIME"
description="JSCH_JOBV_NEXT_DATE_TIME_DESC"
format="%Y-%m-%d %H:%I:%S"
readonly="readonly"
class="readonly" />
In database the value is stored for the field as below
2020-05-19 15:05:00
But on the screen I am rendering using the code
echo $this->form->renderField('job_next_run_date_time');
and it is displaying as below
2020-05-19 03:03:00
Why the hours part is not shown in 24 hours and minute part is changed from 05 to 03?
When changed the calendar field to a normal text field it displayed correctly as below
2020-05-19 15:05:00
On further investigation on the core Joomla library I found the below piece of code in \libraries\joomla\form\fields\calendar.php
. I added an echo statement before and after.
echo $this->value; //malai this prints 2020-05-19 15:05:00
$tz = date_default_timezone_get();
date_default_timezone_set('UTC');
$this->value = strftime($this->format, strtotime($this->value));
date_default_timezone_set($tz);
echo $this->value; //malai this prints 2020-05-19 15:03:00
Does this gives any clue???
timeformat="24"
. I'm not sure since this should be the default value on this but maybe it can help. I do not have any clue about the altered minutes though, I've never seen that behavior at calendar field.timeformat="24"
dont have any effect.date
object or you just take the date directly from the database?JDate
object from the data with one or two extra lines of code like$date = new Date('2012-12-1 15:20:00');
and see if it helps or not... Link: docs.joomla.org/How_to_use_JDate