[Solved] Get date for past weekday with Smarty


This is logic that you would normally put inside your PHP script, not smarty. Try something like this:

empty($_GET['day']) ? $day = date('l') : $day = $_GET['day'];
$date = strtotime("last {$day}");
echo "News from ".date("l, F j", $date);

This script assumes that you pass the day as a GET parameter, for example index.php?day=monday. You can assign what’s echo’ed to smarty. strtotime() and date() are both powerful and flexible functions, have a look at their PHP documentation

1

solved Get date for past weekday with Smarty