How to add additional day/days to a UNIX timestamp and convert it to readable DateTime format

This guide shows how to take a UNIX timestamp (e.g. `1600259200`), add one day to it and present it in a readable DateTime format (e.g. `YYYY-MM-DD`). For this guide we assume the UNIX timestamp originates from an event parameter, but it can also come from elsewhere - user attribute or Linked Data, to name a few examples.

Steps:

  1. Get the event parameter with the following JINJA code
    {{ parameter.testParam }}
  2. Convert the timestamp to a time parameter object with the sectotime JINJA function:
    {{ parameter.testParam | sectotime }}
  3. Add one additional day to the time parameter via the plus_time function:
    {{ parameter.testParam | sectotime| plus_time(1,'days')}}
  4. Format the time to `YYYY-MM-DD` format with the datetimeformat function:
{{ parameter.testParam | sectotime| plus_time(1,'days') |datetimeformat("%y-%m-%d")}}

As a result, the timestamp parameter(`1600259200`) will be displayed as `20-09-18` in the message.

 

Useful resources:


Was this article helpful?
Have more questions? Submit a request