Jira smart values - date and time
You can manipulate and format the created, updated, due date, and resolution date fields, as well as the Date Picker custom field, within fields that support smart values.
On this page:
Date and time smart values
The following smart values are available to access and format date and time fields:
- now
- Date formats
- diff(date)
- isAfter(date)
- isBefore(date)
- isEquals(date)
- compareTo(date)
- plusDays / minusDays
- plusHours / minusHours
- plusWeeks / minusWeeks
- plusMillis / minusMillis
- plusMinutes / minusMinutes
- plusMonths / minusMonths
- plusSeconds / minusSeconds
- plusYears / minusYears
- plusBusinessDays/minusBusinessDays
- toBusinessDay/toBusinessDayBackwards
- setTimeZone / convertToTimeZone
- To date with time conversion
- withDayOfMonth
- withNextDayOfWeek
- withHour
- withMillis
- withMinute
- withMonth
- withSecond
- withYear
- withDayOfYear
- Set the day component of the date
- Attributes
now
Smart value to reference the current date and time:
{{now}}
{{now.plusDays(7).jqlDate}}
For example:
// 1st of May this year
{{now.startOfMonth.withMonth(5)}}
// 1st of May next year
{{now.startOfMonth.withMonth(5).plusYears(1)}}
// last day of May
{{now.withMonth(5).endOfMonth}}
// first business day in May
{{now.withMonth(5).firstBusinessDayOfMonth}}
// last business day in May
{{now.withMonth(5).lastBusinessDayOfMonth}}
Date formats
For example:
{{now.jiraDate}}
{{now.format("dd/MM/yyyy")}}
{{now.shortDate}}
Format | Thursday, November 1, 1979 6:23:12 AM EST |
---|---|
Default (none specified) | Nov 1, 1979 6:23:12 AM |
jiraDate | 1979-11-01 |
jiraDateTime | 1979-11-01T06:23:12.0-0500 |
jqlDate | 1979-11-01 |
jqlDateTime | 1979-11-01 06:23 |
shortDate | 11/1/79 |
shortTime | 6:23 AM |
shortDateTime | 11/1/79 6:23 AM |
mediumDate | Nov 1, 1979 |
mediumTime | 6:23:12 AM |
mediumDateTime | Nov 1, 1979 6:23:12 AM |
longDate | November 1, 1979 |
longTime | 6:23:12 AM EST |
longDateTime | November 1, 1979 6:23:12 AM EST |
fullDate | Thursday, November 1, 1979 |
fullTime | 6:23:12 AM EST |
fullDateTime | Thursday, November 1, 1979 6:23:12 AM EST |
format("<pattern>") e.g. format("dd/MM/yyyy") Please refer to Java documentation for pattern syntax. | 01/11/1979 |
diff(date)
{{now.diff(issue.created).days}}
Units available:
- millis
- seconds
- minutes
- hours
- days
- weeks
- months
- years
- businessDays
- prettyPrint
- abs
"prettyPrint" displays the difference in words. E.g. 2 days 3 hours
isAfter(date)
{{now.isAfter(issue.created)}}
(returns true/false)
isBefore(date)
{{now.isBefore(issue.created)}}
(returns true/false)
isEquals(date)
{{now.isEquals(now)}}
(returns true/false)
compareTo(date)
{{now.compareTo(issue.created)}}
(returns number){{issue.created.compareTo(now)}}
(returns number){{now.compareTo(now)}}
returns 0
plusDays / minusDays
{{now.plusDays(1)}}
{{now.minusDays(1)}}
plusHours / minusHours
{{now.plusHours(1)}}
{{now.minusHours(1)}}
plusWeeks / minusWeeks
{{now.plusWeeks(1)}}
{{now.minusWeeks(1)}}
plusMillis / minusMillis
{{now.plusMillis(1)}}
{{now.minusMillis(1)}}
plusMinutes / minusMinutes
{{now.plusMinutes(1)}}
{{now.minusMinutes(1)}}
plusMonths / minusMonths
{{now.plusMonths(1)}}
{{now.minusMonths(1)}}
plusSeconds / minusSeconds
{{now.plusSeconds(1)}}
{{now.minusSeconds(1)}}
plusYears / minusYears
{{now.plusYears(1)}}
{{now.minusYears(1)}}
plusBusinessDays/minusBusinessDays
Business days are considered to be Monday to Friday, 9am to 6pm.
{{now.plusBusinessDays(1)}}
{{now.minusBusinessDays(1)}}
toBusinessDay/toBusinessDayBackwards
Business days are considered to be Monday to Friday, 9am to 6pm.
{{toBusinessDay}}
{{toBusinessDayBackwards}}
setTimeZone / convertToTimeZone
{{convertToTimeZone("Australia/Sydney")}}
Converts the time to what it would be in the new timezone. E.g. 7am UTC will become 5pm Sydney time. This is useful when wanting to print dates in a specific timezone or perform calculations based on the hours of a specific timezone.
{{setTimeZone("Australia/Sydney")}}
Changes the timezone but maintains the same date/time. e.g. 7am UTC will get converted to 7am Sydney time
Note: Timezones must be supplied in the {area}/{city} format e.g. America/Los_Angeles
For a list of timezones, refer to the Java documentation.
To date with time conversion
The following functions can be used to convert a date to a date with a time component:
{{now.toStartOfDay}}
{{now.toCurrentTime}}
{{now.toDateTimeAtStartOfDay}}
{{now.toDateTimeAtStartOfDay(timezone)}}
{{now.toDateTimeAtCurrentTime}}
{{now.toDateTimeAtCurrentTime(timezone)}}
withDayOfMonth
{{now.withDayOfMonth(15)}}
withNextDayOfWeek
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 one of these as values: MON, TUE, WED, THU, FRI, SAT, SUN.
{{now.withNextDayOfWeek("TUE")}}
will return the next Tuesday{{now.withNextDayOfWeek("MON").withHour(14).withMinute(0)}}
will return the next Monday at 2pm
withHour
{{now.withHour(20)}}
withMillis
{{now.withMillis(500)}}
withMinute
{{now.withMinute(59)}}
withMonth
{{now.withMonth(10)}}
withSecond
{{now.withSecond(0)}}
withYear
{{now.withYear(1979)}}
withDayOfYear
{{now.withDayOfYear(355)}}
Set the day component of the date
{{now.endOfMonth}}
{{now.startOfMonth}}
{{now.firstBusinessDayOfMonth}}
{{now.lastBusinessDayOfMonth}}
// Parameters: day of week (1-7)
{{now.firstOfTheMonth(1)}}
{{now.lastOfTheMonth(1)}}
// Parameters: nth of month (1-5), day of week (1-7)
{{now.ofTheMonth(2, 1)}}
Attributes
You can retrieve individual attributes of a day, such us the month or the day of the week the issue was created. For example:
// Get today's day of the month
{{now.dayOfMonth}}
// Get the day of the week the issue was created
{{issue.created.dayOfWeekName}}
// Get the day name of the week in French
{{issue.created.locale("fr").dayOfWeekName}}
Attributes |
---|
millis |
second |
minute |
hour |
dayOfMonth |
monthOfYear |
year |
dayOfYear |
dayOfWeek |
dayOfWeekName |
dayOfWeekShortName |
weekOfYear |
zoneId |
toDays |
isLeapYear |
lengthOfMonth |
lengthOfYear |
timeZoneShort |
timeZoneFull |
timeZoneNarrow |
offsetShort |
offsetFull |
offsetNarrow |
Examples of using smart values with dates and time
Check out some examples of using smart values with dates and time:
Formatting dates
You specify the format of a date at the end of the smart value:
// using inbuilt formats
{{issue.resolutiondate.asLongDateTime}}
{{issue.MyDateFieldName.longDateTime}}
{{issue.created.jqlDateTime}}
{{issue.created.mediumTime}}
{{issue.Sprint.endDate.jiraDate}} - format the Sprint field's end date into a format suitable to set another field
// Or, you can specify the format
{{issue.dueDate.format("dd/MM/yyyy")}}
{{issue.created.as("dd MMM")}}
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
{{issue.created.withLocale("fr").asLongDateTime}}
// Prints the issue's created date in French Canadian
{{issue.created.locale("fr_CA").longDateTime}}
// Prints the issue's created date in the locale of the reporter
{{issue.created.locale(issue.reporter.locale).longDateTime}}
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 time zone,
// e.g. 10am UTC converts to 8pm AEST
{{issue.created.convertToTimeZone("Australia/Sydney")}}
// Converts the issue's created time to the new time zone and keeps the same
// times/dates. E.g. 10am UTC changes to 10am AEST
{{issue.created.setTimeZone("Australia/Sydney")}}
For a list of timezones, please refer to Java documentation.
Specify a user's time zone
// Prints the issue's created time in the reporters time zone.
{{issue.created.convertToTimeZone(issue.reporter.timeZone)}}
Manipulating dates
Manipulate dates by setting parts of the date or adding/subtracting values from it:
// Add 7 days to the current time
{{now.plusDays(7)}}
// You can chain functions
// Set the created date to November 1st
{{issue.created.withDayOfMonth(1).withMonth(11)}}
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
{{now.toBusinessDay()}}
// The next business day after 3 days
{{now.plusDays(3).toBusinessDay()}}
// The previous business day
{{now.toBusinessDayBackwards()}}
// Adds 6 business days to today
{{now.plusBusinessDays(6)}}
// The first business day of the month
{{now.firstBusinessDayOfMonth}}
// The last business day of the month
{{now.lastBusinessDayOfMonth}}
// The number of business days beeween when the issue was created and today
{{now.diff(issue.created).businessDays}}
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
{{now.diff(issue.created).hours}}
// Gets the number of days between two dates
{{now.diff(issue.created).days}}
// To show positive dates use the "abs" method
{{now.diff(issue.created).abs.days}}
Comparing two dates
You can compare two dates. These methods take another date as the parameter.
// Returns "true"
{{now.isAfter(issue.created)}}
Compare dates using the Compare condition.
Converting text to dates
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. You can convert different text formats into a date object by using the following smart values:
- To convert a text like "2024 10 20" into a date, use this smart value.
{{issue.summary.toDate("yyyy MM dd")}}
- To convert a text like "10/20/2024" into a date, use this smart value.
{{issue.summary.toDate("MM/dd/yyyy")}}
- To convert a text like "20/10/2024" into a date, use this smart value.
{{issue.summary.toDate("dd/MM/yyyy")}}
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)
{{fieldChange.fromString.toDate.plusDays(1).longDate}}