Get started > Use case scenarios - customizing with business rules > Using a rule to add the date and time (in a readable format) to a comment

Using a rule to add the date and time (in a readable format) to a comment

In Service Management, dates and times are stored using a Unix timestamp. You can use the format command to display these values in a more user friendly manner.

For example, to add the date and time in a readable format to requests:

  1. From the main menu, select Administration > Configuration > Records > Processes and Rules.

  2. Select the Request record type.

  3. In the tree on the left, select Request (the top level of the tree).
  4. In After change, click Add, then select Simple rule.

  5. In Actions, select Add comment.

  6. Click OK.

    Screenshot of add comment rule template

  7. Click comment, and add the following expression:

    ${format(now(),'long')}
  8. Click Save.

    Screenshot of add comment rule

The date and time appears as follows:

Screenshot of date and time displayed

Offset for time zone differences

Date and time values are stored according to the server time. If the server time is different from your local time, you need to use the appropriate offset to display values in local time.

For example, if the server location is in London, England and your local time is that of Paris, France, the offset is one hour. To display local time in Paris, you change the expression by adding the appropriate number of milliseconds as follows:

${format(now()+3600000,'long')}

Display of time zone

The long parameter adds the time zone of the server to the comment. For example, in the above image, this displays as PDT. If you do not want this to display, replace long with short.