在 PHP 中,可以使用 strtotime() 函数来生成相对日期表达式。以下是一些示例:
// 获取当前日期$currentDate = date('Y-m-d');// 获取明天的日期$tomorrow = date('Y-m-d', strtotime('+1 day'));// 获取昨天的日期$yesterday = date('Y-m-d', strtotime('-1 day'));// 获取下个月的日期$nextMonth = date('Y-m-d', strtotime('+1 month'));// 获取上个月的日期$lastMonth = date('Y-m-d', strtotime('-1 month'));// 获取一周后的日期$nextWeek = date('Y-m-d', strtotime('+1 week'));// 获取一周前的日期$lastWeek = date('Y-m-d', strtotime('-1 week'));通过使用 strtotime() 函数,可以轻松地生成各种相对日期表达式,从而方便地操作日期。


