This article will cover how you can apply Liquid markup to a date placeholder in Zendesk. This can be useful both within Zendesk and in combination with Sweethawk apps in order to automate your workflows.



Did you know...

You can test out any liquid that you produce in real time using the free Liquid Placeholders app here

Liquid markup can be used to build flexible workflows using a multitude of SweetHawk apps including Tasks and sub-tickets, Approve, Timers, Calendar, Notify and more!


This article contains the following sections:


Change the date format

If you have used placeholders within Zendesk, you are probably aware that the format is always (YYYY-MM-DD) for date fields and may have resigned to the fact that this cannot be changed. Using liquid markup, we change the format to be more region friendly based on where your agents/customers are located in the world.

Here is a list of values you can use to customize the output of your date.

Input: Output:
%a Wed
%A Wednesday
%d 13
%b Oct
%B October
%m 10
%y 21
%Y 2021




To give you an idea of how this works, the following placeholder will output the same format as what Zendesk already provides.

Input: {{ticket.ticket_field_<id> | date: '%Y-%m-%d'}}
Output: 2021-10-13 (YYYY-MM-DD)


Now we can adjust the input to modify the output format.

Input: {{ticket.ticket_field_<id> | date: '%d/%m/%Y'}}
Output: 13/10/2021 (DD/MM/YYYY)


Here is another example of how you can format the date if you would like it to be more presentable.

Input: {{ticket.ticket_field_<id> | date: '%a, %b %d, %Y'}}
Output: Wed, Oct 13, 2021



Change the time format

Depending on the placeholder, you can also output the time along with the date when a more precise measurement is required. Here are some points to be aware of when dealing with time.

  • There is no custom time field within Zendesk.
  • A custom date field contains a time value, however, it is not recorded and will be set at midnight.
  • The timezone will be in UTC unless the placeholder specifically states "with_time" in which case, it will match your timezone in Zendesk.

Here are some examples of placeholders that do record the time.

  • "now" or "today"
  • ticket.created_at 
  • ticket.created_at_with_time
  • ticket.updated_at
  • ticket.updated_at_with_time
  • ticket.comment.created_at
  • ticket.comment.created_at_with_time

Here is a list of values you can use to customize the output of your time.

Input: Output:
%H 17 (Hour)
%M 53 (Minute)
%S 48 (Second)
%Z Timezone


Let's first start with "now". This will output the current date and time but you must specify the format, otherwise, it will simply output the word "now".

Let's combine what we have learnt from both date and time to output the following:

Input: {{'now' | date: '%B %d, %Y - %H:%M:%S'}}
Output: October 13, 2021 - 17:53:48


Here are some more examples using different placeholders

Input: {{ticket.created_at}}
Output: Oct 13

Input: {{ticket.created_at_with_time}}
Output: Oct 13, 12:53

Input: {{ticket.created_at | date: '%B %d, %Y - %H:%M:%S'}}
Output: October 13, 2021 - 17:53:48

Input: {{ticket.created_at_with_time | date: '%B %d, %Y - %H:%M:%S %Z'}}
Output: October 13, 2021 - 12:53:00 UTC


Note that the placeholder using "with_time" does not record seconds so you will need to take this into account if you require precise measurements.



Change the date/time

Now that we know how to format the date and time, we can move on to modifying the actual date and time. The basic premise for changing the date/time is by adding or subtracting the number of seconds required.

Here is a basic example of how to modify the date to be one day from now.

Input: {{'now' | date: '%s' | plus: 86400 | date: '%Y-%m-%d'}}
Output: 2021-10-14


We can simplify this further by substituting this with an assigned value – in this case, "s" equals the number of days – then applying math to output this in seconds.

{% assign s = 3 | times: 24 | times: 60 | times: 60 %}


Let's combine the two in order to change the date to be one week from now.

Input: {% assign s = 7 | times: 24 | times: 60 | times: 60 %}{{'now' | date: '%s' | plus: s | date: '%Y-%m-%d'}}
Output: 2021-10-20


Now let's use a custom date field as the input and modify the date to be 30 days relative to this date. For the purpose of this example, the original date is October 1.

Input: {% assign s = 30 | times: 24 | times: 60 | times: 60 %}{{ticket.ticket_field_<id> | date: '%s' | plus: s | date: '%Y-%m-%d' }}
Output: 2021-10-31


Note that I am specifically using the format "%Y-%m-%d" for all of these examples because Zendesk uses this format on custom date fields. This is useful to know in the next part of the article, however, it is not required.

Was this article helpful?
6 out of 6 found this helpful



Please sign in to leave a comment.