I want add condition to a variable if the day of this condition is a Monday, Example:
{if $order.details.order_date == monday}
{$order.details.order_date|replace:'/':'-'|cat:' +8 days'|date_format:'%A, %e de %B del %Y'}
{/if}
How can I read from a variable if the date is a monday?
Option 1:
Also pass the calculated day of the week, along with the date, in $order.details, from PHP
Option 2:
Apply a filter to $order.details.order_date:
{if $order.details.order_date|date_format:'l' == 'Monday'}
Depending on your version of Smarty you can also try:
{if $order.details.order_date|date_format:'%u' == 1}
Where the result of the date_format filter is an "ISO-8601 numeric representation of the day of the week, 1 (for Monday) through 7 (for Sunday)", see strftime() for more information
Alternatively you can also try to assign the value to a variable before testing it:
{$dayOfWeek = {$order.details.order_date|date_format:'%u'}}
{if $dayOfWeek == 1}
You can try to convert the variable and then apply the filter:
{$dateYMD = {{$order.details.order_date|substr:6:4}|cat:'-'|cat:{$order.details.order_date|substr:3:2}|cat:'-'|cat:{$order.details.order_date|substr:0:2}}}
{if $dateYMD|date_format:'%u' == 1}
but you could receive some 'deprecated' messages from PHP if they are not disabled, since substr will be removed in future smarty releases.
You can also try replacing the slashes with dashes, it seems to work but I do not garantee for that:
{if $order.details.order_date|replace:'/':'-'|date_format:'%u' == 1}