Jira Automation Smart Value: Using {{now}} to get current time

Jira Automation Smart Value: Using {{now}} to get current time

The {{now}} Smart Value captures the current date and time in UTC+00:00. This is particularly useful for setting due dates, triggering actions based on the current time, or filtering issues updated within a specific timeframe.

Example of {{now}}

If the current date and time is July 12, 2024, 2:40am UTC:

{{now}}

// returns

2024-07-12T02:40:37.0+0000

Date format {{[date].[dateformat]}}

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:

To return current time only

{{now.shortTime}}

// returns

9:30 AM
💡
When using Jira Automation and dealing with date and time values, it’s important to account for the fact that the default time zone is UTC (Coordinated Universal Time). To adjust the time to your local time zone, you can use the minusHours()/ plusHours() functions.

Examples:

Assume your local time zone is UTC+2 (Central European Time).

{{now.plusHours(2)}}

UTC - 7 (Pacific Time Zone):

{{now.minusHours(7).shortTime}}

We can also use:

Date difference: {{[date1].diff([date2]).[unit]}}

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.

Example:

For an issue that was created 4 weeks ago:

{{now.diff(issue.created).weeks}}

//returns

-4
💡
use abs to returns the value as a positive number. ex:
{{now.diff(issue.created).weeks.abs}} will returns a positive number

Date after: {{[date1].isAfter([date2])}}

Returns true if date1 is after date2, and false if not.

Example:

{{now.isAfter(issue.created)}}

//returns

true

Date same: {{[date1].isEquals[(date2)]}}

Returns true if date1 and date2 are same, and false if not.

{{now.isEquals(issue.created)}}

//returns

false

Date plus/minus unit: {{[date].plus/minusUnit}}

Takes the given date and time, adds/minus 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 {{now}} is 6:31 PM:

{{now.plusHours(7).minusMinutes(15).shortTime}}

// return

1:16 AM

Convert timezone date: {{[date].convertToTimeZone([timezone])}}

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:

{{now.convertToTimeZone("America/Los_Angeles").shortTime}}

//returns

1:17 PM

Do you enjoy this blog post?

Read more