我在我的一个脚本中运行了以下代码,它运行良好,但感觉相当笨重且冗长。我觉得可能有更短的方法来实现相同的结果。我的意思是不使用简写 if 语句。
我需要确定今天是否是星期四,如果不是,则使用上一个星期四作为日期。任何想法/想法都会很棒。
<?php
if (new Carbon('this thursday') > new Carbon()) {
$date = Carbon('this thursday');
} else {
$date = Carbon('last thursday');
}
?>