php strtotime获取前两周的周日
要获取前两周的周日,可以使用strtotime函数结合date函数来实现。
$currentDate = date('Y-m-d'); // 当前日期
$twoWeeksAgo = strtotime('-2 weeks', strtotime($currentDate)); // 获取前两周的日期
// 获取前两周的周日
$lastSunday = date('Y-m-d', strtotime('last Sunday', $twoWeeksAgo));
$secondLastSunday = date('Y-m-d', strtotime('last Sunday', strtotime($lastSunday)));
echo $secondLastSunday; // 输出前两周的周日日期
这段代码会先获取当前日期,然后使用strtotime函数获取前两周的日期。接着,使用strtotime函数结合"last Sunday"参数获取前两周的最后一个周日日期,并使用date函数格式化输出结果。
原文地址: http://www.cveoy.top/t/topic/h1zV 著作权归作者所有。请勿转载和采集!