Posted on Leave a comment

Customizing Date Format in JIRA

Jira Logo

Sometimes you might want (or need) to change the default date-time format set in JIRA. Out of the box the format is set to d/MMM/yy, which translates to for instance 1/Jan/13.

Luckily, this setting can be easily edited through the administration interface under System » General Configuration » Advanced (scroll down the General Configuration page), as shown below:

JIRA -> General Configuration -> Advanced

In order to change the format for dates and date-times you need to look for four options:

JIRA Datetime Format Options

Whereas jira.date.picker.* takes care of settings the format used for date strings, jira.date.time.picker.* sets the desired date-time format. Furthermore, there are two options for each of these settings, one for the client side datepicker (*.javascript.format) and the other for the JAVA formatter (*.java.format).

Matching Formats

Be aware of the fact that changing the way dates and datetime strings are display on the client side must conform to the format used on the server side, i.e. the server must be able to interpret the dates posted. Thus, it is required that the JavaScript and JAVA formats specified in the configuration match.

In case your settings do not match you will get an error such as “Please enter the date in the format “d/MMM/yy” when trying to save dates using the date picker.

Possible combinations for these format specifications can be found on Atlassian’s Configuring date picker formats page.

Look and Feel

Optionally. you can edit the way dates and datetime are displayed to users through the Look and Feel section in the administration interface (System » User Interface » Look and Feel):

JIRA Look and Feel Date Time Formats

Posted on 5 Comments

Zend_Date and MySQL’s datetime format

Despite Zend_Date‘s power and elegance to handle all kinds of different date and time formats, it (still) lacks the ability to cope with MySQL’s datetime formated strings out-of-the-box.

Thus, instead of being able to simply do something like

$date = new Zend_Date();
echo $date->toString(Zend_Date::MYSQL_DATETIME);

one has to manually define MySQL’s datetime syntax, as shown in the following:

$date = new Zend_Date();
echo $date->toString('YYYY-MM-dd HH:mm:ss');

I personally don’t quite see why this commonly used format has not yet been added to Zend_Date.

In the meantime, I have found it to be the most convenient to define the MySQL datetime format string as a constant. Although this is no big deal but still, I would rather like to see this simple piece of formating code inside Zend_Date.

UPDATE
I have come across a strange problem when trying to create new Zend_Date objects using custom formats, such as the MySQL datetime format shown above, e.g.:

$date = new Zend_Date($mysqlDatetimeString, MYSQL_DATETIME); //will create a wrong date...

Instead it seems best to create custom format dates/times using a two way approach:

$date = new Zend_Date(); //create new object, by default time()
$date->set($mysqlDatetimeString, MYSQL_DATETIME); //will create correct date