- Examples of using smart values with dates
- Formatting dates
- Locale (location based date format)
- Time zone
- Specify a user’s timezone:
- Manipulating dates
- Attributes of a date
- Calculating business days
- Calculating the difference between two dates
- Comparing two dates
- Converting text to dates
- Referencing the current date/time
- Example
- Change the time format to 24 hours in Jira
- Purpose
- Solution
- Jira smart values — date and time
- Example
- Example
- Example
- Example
- Example
- Example
- Example
- Example
- Example
- Example
- Example
- To date with time conversion
- Example
- Example
- Example
- Available attributes
- Example
- Set the day component of the date
- Customizing Date Format in JIRA
- Matching Formats
- Look and Feel
Examples of using smart values with dates
You can manipulate and format created, updated, duedate, resolutiondate dates (as well as the Date Picker custom field) inside fields that support Smart Values. Date functions and attributes are in the date reference section.
Formatting dates
You specify the format of a date at the end of the smart value:
// using inbuilt formats > > > > > - format the Sprint field's end date into a format suitable to set another field // Or, you can specify the format <> <>
See our reference guide for a complete list of available date formats .
Locale (location based date format)
You can specify the locale to print the dates in (default is «US» locale).
// Prints the issue's created date in French > // Prints the issue's created date in French Canadian > // Prints the issue's created date in the locale of the reporter >
For a list of locales, please refer to Java documentation.
Time zone
Dates are displayed in Jira’s default timezone.
// Converts the issue's created time to the new timezone, // e.g. 10am UTC converts to 8pm AEST <> // Converts the issue's created time to the new timezone and keeps the same // times/dates. E.g. 10am UTC changes to 10am AEST <>
For a list of timezones, please refer to Java documentation .
Specify a user’s timezone:
// Prints the issue's created time in the reporters timezone. >
Manipulating dates
Manipulate dates by setting parts of the date or adding/subtracting values from it:
// Add 7 days to the current time > // You can chain functions // Set the created date to November 1st >
Attributes of a date
Retrieve individual attributes of a day, e.g. the month
// Get today's day of the month > // Get the day of the week the issue was created > // Get the day name of the week in French >
Calculating business days
Plus/minus business days from the current date or find the closest business day to the current date. Business days are considered Monday through Friday.
// The next business day > // The next business day after 3 days > // The previous business day > // Adds 6 business days to today > // The first business day of the month > // The last business day of the month > // The number of business days beeween when the issue was created and today >
Calculating the difference between two dates
The «diff» method to calculate the difference between two dates by passing in another date and then specifying the unit to measure.
// Gets how many hours since an issue was created > // Gets the number of days between two dates > // To show positive dates use the "abs" method >
Comparing two dates
You can compare two dates. These methods take another date as the parameter.
Converting text to dates
When a date is text, e.g. in the changelog, dates are stored as text:
Convert the text to a date if it’s in the right format. You can specify the format to convert from, by adding the param. The example below converts text, e.g. «2017 6 11», into a date object.
Once you’ve converted text to a Date object, you’ll may need to transform it further, e.g. for a field changed (e.g. listening for a change in date)
Referencing the current date/time
You can reference the current date and time using >
Example
// 1st of May this year > // 1st of May next year > // last day of May > // first business day in May > // last business day in May >
Change the time format to 24 hours in Jira
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms .
Purpose
Users would like the time in Jira to show in the 24 hours format rather than the 12 hours format.
This KB is to change the time format across Jira. If you’re trying to change the time format for specific user(s) this KB does not apply. JRASERVER-10613 — Getting issue details. STATUS
Solution
In order to change this configuration in Jira Server/Data Center you must have the Jira System Administrator global permission.
You may refer to this page for more information: Changing the Due Date Input Format
- Go to the General Configuration page of your Jira instance
- Keyboard shortcut : ‘G’ + ‘G’ + Start typing ‘General Configuration’ and hit Enter.
- > System > General Configuration
- or navigate to $JIRAURL/secure/admin/ViewApplicationProperties.jspa
jira.date.picker.javascript.format=%e/%b/%y jira.date.time.picker.javascript.format=%e/%b/%y %H:%M jira.date.time.picker.java.format=dd/MMM/yy HH:mm jira.date.picker.java.format=dd/MMM/yy
- Keyboard shortcut : ‘G’ + ‘G’ + Start typing ‘Look and feel’ and hit Enter.
- > System > User Interface > Look and Feel
- or navigate to $JIRAURL/secure/admin/LookAndFeel!default.jspa
Jira smart values — date and time
The following smart values are available to access and format date and time fields.
Check out how we use smart values in our Jira automation template library.
For more examples of how these smart values can be used, see Use smart values to manipulate and format dates.
Returns the current date and time.
Example
If the current date and time is August 18, 2020, 2:40am UTC:
Takes a date and time that you provide, and returns it in a format of your choosing. This is useful for converting the default output for dates (jiraDateTime), to a format that is easier to read. You can add a dateformat to the end of any of the date smart values listed on this page.
The full list of formats are below:
Thursday, November 1, 1979 6:23:12 AM UTC
November 1, 1979 6:23:12 AM EST
Thursday, November 1, 1979 6:23:12 AM EST
Refer to the Java documentation for pattern syntax.
Example
Returns the amount of time between date1 and date2 , in the unit specified. If date2 is earlier than date1 , the value returned will be negative.
The units that can be used with this smart value are:
- millis
- seconds
- minutes
- hours
- days
- weeks
- months
- years
- businessDays
You can also change the format of the output using the following:
- prettyPrint — displays the difference in words, e.g.: 2 days 3 hours.
- abs — returns the value as a positive number.
Example
For an issue that was created 4 weeks ago:
Returns true if date1 is after date2 , and false if not.
Example
Returns true if date1 is before date2 , and false if not.
Example
Returns true if date1 and date2 are the same, and false if not.
Example
Compares date1 to date2 , to find which date is earlier. Returns:
- -1, if date1 is earlier than date2
- 1, if date2 is earlier than date1
- 0, if the two dates are the same
Takes the given date and time, adds the number of the unit specified, and returns the resulting date and time. The units that can be used are:
- Millis
- Seconds
- Minutes
- Hours
- Days
- Weeks
- Months
- Years
- BusinessDays (business days are considered to be Monday to Friday, 9am to 6pm)
Example
If the current value of > is 2020-08-20T13:12:03.1+0000:
Takes the given date and time, subtracts the number of the unit specified, and returns the resulting date and time. The units that can be used are:
- Millis
- Seconds
- Minutes
- Hours
- Days
- Weeks
- Months
- Years
- BusinessDays (business days are considered to be Monday to Friday, 9am to 6pm.)
Example
Takes the given date, and returns the next business date. If the given date is a business day, then it will return the given date.
Example
If the value of > is 2020-08-30T23:36:28.7+0000:
Takes the given date, and returns the previous business day.
Example
If the value of > is 2020-08-30T23:36:28.7+0000:
Takes a given time, and sets (not converts) that time to the given time zone. i.e.: It prints that same time, but simply changes the timezone. You can find valid inputs for timezones here (see Canonical ID column).
If the value of > is 2020-08-30T03:17:06.2+0000:
Takes a given time, and converts it to the time in the given time zone. You can find valid inputs for timezones here (see Canonical ID column).
Example
If the value of > is 2020-08-30T03:17:06.2+0000:
To date with time conversion
Takes a given date, and converts it to a date with a time component.
Example
Takes a given date and time, and returns that same date and time, but with the day of the month set to the date that was inputted.
Example
If the value of > is 2020-08-30T03:17:06.2+0000:
Sets the date to the next matching day. If you’re already on that day, then it will return the next week. You can use the following values: MON, TUE, WED, THU, FRI, SAT, SUN.
Example
Takes a given date and time, and sets the date or time to whatever is described in the attribute.
Available attributes
- millis
- second
- minute
- hour
- dayOfMonth
- monthOfYear
- year
- dayOfYear
- dayOfWeek
- dayOfWeekName
- dayOfWeekShortName
- weekOfYear
- zoneId
- toDays
- isLeapYear
- lengthOfMonth
- lengthOfYear
- timeZoneShort
- timeZoneFull
- timeZoneNarrow
- offsetShort
- offsetFull
- offsetNarrow
Example
If the value of > is 2020-08-30T03:17:06.2+0000:
Set the day component of the date
Takes a given date, and returns that date with the day component set to whatever was inputted.
Returns the date and time of the end of the month.
Returns the date and time of the start of the month.
Returns the first business day of the month. Business days are considered to be Monday to Friday, 9am to 6pm.
Returns the last business day of the month. Business days are Monday to Friday, 9am to 6pm.
Takes the given date, and returns the first specified day of the month. The following inputs correspond to the following days:
- 1 — Monday
- 2 — Tuesday
- 3 — Wednesday
- 4 — Thursday
- 5 — Friday
- 6 — Saturday
- 7 — Sunday
If the value of > is 2020-09-01T03:17:06.2+0000, then > will return the first Monday of September, 2020
Takes the given date, and returns the last day of the month. The following inputs correspond to the following days:
- 1 — Monday
- 2 — Tuesday
- 3 — Wednesday
- 4 — Thursday
- 5 — Friday
- 6 — Saturday
- 7 — Sunday
If the value of > is 2020-09-01T03:17:06.2+0000, then > will return the last Friday of September, 2020
Takes the given date, and returns the nth day of that month. If the value of > is 2020-09-01T03:17:06.2+0000, then <
Customizing Date Format in JIRA
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:
In order to change the format for dates and date-times you need to look for four 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):
This site uses Akismet to reduce spam. Learn how your comment data is processed.