Adding the current date and time
You can set the current date and time in a field using {{time.now}}
To set the time at the beginning of today (00:00:00) use {{time.today}}
Converting to a future or past date
To add a date in the future or in the past, you can add {{time.delta}
} to {{time.now}}
or {{time.today}}
This is particularly helpful for setting a due date for a task.
Convert UNIX timestamp to UTC format
The UNIX time stamp is a way to track time as a running total of seconds. The UNIX time stamp is the number of seconds between a particular date and the UNIX Epoch. This point in time technically does not change no matter where you are located on the globe.
Example of usage:
input : {{1608112432| timestamp_to_time}}
output: 12-16-2020 01:53 AM
Setting a relative time
You can also use {{time.delta}}
to get relative times. The available options are years, months, weeks, days, hours, minutes, and seconds. Note that all of them are plural, as opposed to a singular year, or month, which are used for absolute time.
For example, to get the same time one hour from now you can use
{{time.now + time.delta(hours=1)}}
To get a time at the beginning of the day one week from now, use
{{time.today + time.delta(days=7)}}
Months and years are based on the current date and how many days are in a given month. Using {{time.now + time.delta(months=1)}}
results in the same date one month from now, unless the next month has fewer days than the current day of the month. Then, it results in the last day of next month.
For example, if today is 2020-01-27 and we add time.delta(months=1)
, the result is 2020-02-27, but if today is 2020-01-31, since February 2020 has 29 days, the result will be 2020-02-29.
Setting an absolute time
You can also use {{time.delta}}
to get an absolute date or time in a year, month, day, hour, minute, or second from now.
For example, to get same date and time as now in 2016 you can use:
{{time.now + time.delta(year=2016)}}
Adding a time zone filter
All date and times in Pipelines are in UTC. In general, you won’t need to do any time zone conversion yourself if you map between Date/Time fields, even between different channels.
If you want to print the time in a text field in the user’s time zone, however, you can use time zone code.
For example:
The time in Japan is: {{ time.now | timezone('JP') }}
Tip: To find your time zone code, see ‘TZ Identifier’ column in this Wikipedia article.
Specifying date formats
Warning: Do not use the filter below to transform dates between date fields in two different channels. The date format of the channel will be handled automatically by Pipelines. This filter is intended for converting dates into strings for text fields.
Dates displayed in Pipelines are usually formatted as a timestamp. If you need to format the date in another format or display just the date options, you can use code to specify the date format, including
date_ymd
date_dmy
-
date_mdy
sample date code | result |
---|---|
{{time.now|date_ymd}} |
2019-12-15 |
{{time.now|date_mdy}} |
12-15-2019 |
{{time.now|date_dmy}} |
15-12-2019 |
You can also specify the symbol used to separate the dates or specify no symbol. The default symbol is a dash.
Sample date symbol code | Result |
---|---|
{{time.now|date_ymd('')}} |
20191215 |
{{time.now|date_mdy('/')} |
12/15/2019 |
{{time.now|date_dmy('.')}} |
15.12.2019 |
Specifying flexible date formats
For flexible date formats, use the .format function. For example, to return a string representing the previous month, for example, 202008 in the form YYYYMM, use this code:
{{ "{:%Y %m %d}".format(time.now - time.delta(months=1))}}
Where %Y
is the year with century as a decimal number, %m
is the month as a zero-padded decimal number, and %d
is the day of the month as a zero-padded decimal number.
In this example, the output would be:
Inserting a partial date into a field
For example, if you wanted to insert only the YYYYMM into a field (not the date), you could use this code:
{{ time.now.strftime('%Y%m') }}
To clear a date
To clear a date use the jinja expression {{CLEAR}}
in your step. You can also use {{CLEAR}}
to explicitly clear out a field, typically in an update step.