Display Pattern: Date Time
Summary
Show a “Publish Me” message when a date (Id: embargoDate) on a Layer (Id: corporateInformation) is today or before today.
{% assign today_date = 'now' | date: '%s' %}
{% assign embargo_date = data.corporateInformation.embargoDate | local_date %}
{% if today_date => embargo_date %}
Embargo lifted! Publish Me!
{% endif %}
Setup in Picturepark
Layer "Corporate Information"
The date time field "Embargo date"
Field Value Access
To use the date-time value in the display pattern, you must convert it by passing the liquid filter local_date. Local date uses the timezone of the regional settings of my client laptop or like.
data.corporateInformation.embargoDate | local_date
Date Format Syntax
You can format the date to different formats, the syntax is like strf.
%m > month as 01..12
%b > month as Jan…Dec
%Y > year with century as 2021
%y > year without century as 21
{{data.xmpMetadata.xmp.createDate | date: "%Y-%m"}}
Output: 2021-06
{{data.xmpMetadata.xmp.createDate | date: "%Y"}}
Output: 2021
{{data.xmpMetadata.xmp.createDate | date: "%m, %Y"}}
Output: 06, 2021
Use Case
A valid use case is to check if the embargo date is passed and the content can be published:
{% assign today_date = 'now' | date: '%s' %}
{% assign embargo_date = data.corporateInformation.embargoDate | local_date %}
{% if today_date => embargo_date %}
Embargo lifted! Publish Me!
{% endif %}