The date_format modifier can be used to format a timestamp to a specific date format based on the current timestamp ($smarty.now ) or based on a string (strtotime).

date_format

{{$timestamp|date_format}} 

Examples

date_format examples

Format 1: {{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}} 2023-03-14 11:45:46
Format 2: {{$smarty.now|date_format:'%d/%m/%Y'}} 14/03/2023
Format 3: {{"+1 day"|date_format:'%d-%m-%Y'}} 15-03-2023
Format 4: {{"-2 hours"|date_format:'%H uren %M minuten'}} 09 uren 45 minuten
Format 5 *: {{"yesterday"|date_format:"%A, %B %e, %Y - %r"}} Monday, March 13, 2023 - 12:00:00 AM
Format 6: {{"first day of this month"|date_format:"%Y-%m-%d"}} 2023-03-01
Format 7: {{"last day of December this year"|date_format:"%Y-%m-%d"}} 2023-12-31
Format 8: {{"first day of next month"|date_format:"%Y-%m-%d"}} 2023-04-01
Format 9: {{"first day of +2 months"|date_format:"%Y-%m-%d"}} 2023-05-01

* It is possible to display the name of the month in other languages, such as in example "Format 5", using the Deployteq modifier "date_format_locale".

Here's an example with an existing date where you need to add 10 days:

Existing data + 10 days

{{$existingDate = "2023-10-12"}}
        
{{* Add 10 days to the UNIX timestamp *}}
{{$newDateUnix = $existingDate|strtotime+24*60*60*10}}
{{$newDateUnix|date_format:"%d-%m-%Y"}} 22-10-2023
        
{{* Add 10 days based on a text value *}}
{{$newDate = "$existingDate + 10 days"|strtotime|date_format:"%d-%m-%Y"}}
{{$newDate}} 22-10-2023