Automation basics
Understand the general concepts and best practices of automation in Atlassian cloud products.
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 in UTC+00:00.
Example of {{now}}
If the current date and time is August 18, 2020, 2:40am UTC:
1
2
3
4
5
{{now}}
// returns
2020-08-18T02:40:37.0+0000
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:
Format | Thursday, November 1, 1979 6:23:12 AM UTC |
---|---|
Default (none specified) | 1979-11-01T11:23:12.0+0000 |
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 UTC |
fullDate | Thursday, November 1, 1979 |
fullTime | 6:23:12 AM EST |
fullDateTime | Thursday, November 1, 1979, 6:23:12 AM Coordinated Universal Time |
format("<pattern>") e.g. format("dd/MM/yyyy") Refer to the Java documentation for pattern syntax. | 01/11/1979 |
Example of {{[date].[dateformat]}}
1
2
3
4
5
{{now.jiraDate}}
//returns
2020-08-18
1
2
3
4
5
This issue was created on {{issue.created.format("dd/MM/yyyy")}}
//returns
This issue was created on 18/08/2020
1
2
3
4
5
This issue was updated at {{issue.updated.shortTime}}.
//returns
This issue was updated at 2:40 AM.
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 of {{[date1].diff([date2]).[unit]}}
For an issue that was created 4 weeks ago:
1
2
3
4
5
{{now.diff(issue.created).weeks}}
//returns
-4
1
2
3
4
5
This issue was created {{now.diff(issue.created).weeks.abs}} weeks ago.
//returns
This issue was created 4 weeks ago.
Returns true if date1 is after date2, and false if not.
Example of {{[date1].isAfter([date2])}}
1
2
3
4
5
{{now.isAfter(issue.created)}}
//returns
true
Returns true if date1 is before date2, and false if not.
Example of {{[date1].isBefore([date2])}}
1
2
3
4
5
{{now.isBefore(issue.created)}}
//returns
false
Returns true if date1 and date2 are the same, and false if not.
Example of {{[date1].isEquals[(date2)]}}
1
2
3
4
5
{{issue.updated.isEquals(issue.created)}}
//returns
false
Compares date1 to date2, to find which date is earlier. Returns:
<0, if date1 is earlier than date2
>0, if date2 is earlier than date1
0, if the two dates are the same
Example of {{[date1].compareTo([date2])}}
1
2
3
4
5
{{issue.duedate.compareTo(now)}}
//returns
<0 or >0
1
2
3
4
5
{{now.compareTo(now)}}
//returns
0
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 of {{[date].plus[Unit]([number])}}
1
2
3
4
5
{{sprint.startDate.plusDays(14)}}
//returns
2020-08-20T23:27:54.2+0000
If the current value of {{now}} is 2020-08-20T13:12:03.1+0000:
1
2
3
4
5
{{now.plusHours(1).shortTime}}
//returns
2:12 PM
1
2
3
4
5
{{now.plusWeeks(3)}}
//returns
2020-09-10T13:12:03.1+0000:
The following units should be used with "date and time" custom fields:
Millis
Seconds
Minutes
Hours
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 of {{[date].minus[Unit]([number])}}
1
2
3
4
5
{{now.minusDays(5)}}
//returns
2020-08-20T23:27:54.2+0000
1
2
3
4
5
{{now.minusWeeks(7)}}
//returns
2020-07-02T13:12:03.1+0000:
1
2
3
4
5
{{now.minusHours(5).shortTime}}
//returns
8:12 AM
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 of {{[date].toBusinessDay}}
If the value of {{now}} is 2020-08-30T23:36:28.7+0000:
1
2
3
4
5
{{now.toBusinessDay}}
//returns
2020-08-31T23:36:28.7+0000
Takes the given date, and returns the previous business day.
Example of {{[date].toBusinessDayBackwards}}
If the value of {{now}} is 2020-08-30T23:36:28.7+0000:
1
2
3
4
5
{{now.toBusinessDayBackwards}}
//returns
2020-08-28T23: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 {{now}} is 2020-08-30T03:17:06.2+0000:
1
2
3
4
5
{{now.setTimeZone("Australia/Sydney")}}
//returns
2020-08-30T03:17:06.2+1000
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 of {{[date].convertToTimeZone([timezone])}}
If the value of {{now}} is 2020-08-30T03:17:06.2+0000:
1
2
3
4
5
{{now.convertToTimeZone("Australia/Sydney").shortTime}}
//returns
1:17 PM
Takes a given date, and converts it to a date with a time component.
Example of date with time conversion
1
2
3
4
5
6
{{now.toStartOfDay}}
{{now.toCurrentTime}}
{{now.toDateTimeAtStartOfDay}}
{{now.toDateTimeAtStartOfDay(timezone)}}
{{now.toDateTimeAtCurrentTime}}
{{now.toDateTimeAtCurrentTime(timezone)}}
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 of {{[date].withDayOfMonth([date])}}
If the value of {{now}} is 2020-08-30T03:17:06.2+0000:
1
2
3
4
5
{{now.withDayOfMonth(15)}}
// returns
2020-08-15T03: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 of {{[date].withNextDayOfWeek(["day"])}}
1
{{now.withNextDayOfWeek("TUE")}} will return the next Tuesday.
Takes a given date and time, and sets the date or time to whatever is described in the attribute.
millis
second
minute
hour
dayOfMonth
monthOfYear
year
dayOfYear
dayOfWeek
dayOfWeekName
dayOfWeekShortName
weekOfYear
weekOfYearIso
zoneId
toDays
isLeapYear
lengthOfMonth
lengthOfYear
timeZoneShort
timeZoneFull
timeZoneNarrow
offsetShort
offsetFull
offsetNarrow
Example of {{[date].with[attribute](input)}}
If the value of {{now}} is 2020-08-30T03:17:06.2+0000:
1
2
3
4
5
{{now.withYear(2005)}}
//returns
2005-08-30T03:17:06.2+0000
1
2
3
4
5
{{now.withDayOfYear(355)}}
//returns
2020-12-20T03:17:06.2+0000
1
{{now.withNextDayOfWeek("MON").withHour(14).withMinute(0)}} will return the next Monday at 2pm
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.
1
{{now.endOfMonth}}
Returns the date and time of the start of the month.
1
{{now.startOfMonth}}
Returns the week of the year in Western traditional form.
1
{{now.weekOfYear}}
Returns the week of the year in ISO week/date form.
1
{{now.weekOfYearIso}}
Returns the first business day of the month. Business days are considered to be Monday to Friday, 9am to 6pm.
1
{{now.firstBusinessDayOfMonth}}
Returns the last business day of the month. Business days are Monday to Friday, 9am to 6pm.
1
{{now.lastBusinessDayOfMonth}}
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 {{now}} is 2020-09-01T03:17:06.2+0000, then {{now.firstOfTheMonth(1)}} will return the first Monday of September, 2020
1
2
3
4
5
{{now.firstOfTheMonth(1)}}
//returns
2020-09-07T03:17:06.2+0000
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 {{now}} is 2020-09-01T03:17:06.2+0000, then {{now.lastOfTheMonth(5)}} will return the last Friday of September, 2020
1
2
3
4
5
{{now.lastOfTheMonth(5)}}
//returns
2020-09-25T03:17:06.2+0000
Takes the given date, and returns the nth day of that month. If the value of {{now}} is 2020-09-01T03:17:06.2+0000, then {{now.OfTheMonth(2, 1)}} will return the second Monday of September, 2020.
1
2
3
4
5
{{now.ofTheMonth(2, 1)}}
//returns
2020-09-14T03:17:06.2+0000
Was this helpful?