I have the below code running in one of my scripts and it works well, but feels rather clunky and long. I feel like there might be a much shorter way of achieving the same result. I also mean without using a shorthand if statement.
I need to find out if today is thursday and if not use the previous thursday as the date. Any thoughts / ideas would be great.
<?php
if (new Carbon('this thursday') > new Carbon()) {
$date = Carbon('this thursday');
} else {
$date = Carbon('last thursday');
}
?>
$date = Carbon('this thursday'); if ($date <= new Carbon()) { $date = Carbon('last thursday'); }
– Legist