2011-12-28 65 views

回答

4

我会使用DateTime类。

$dateTime = new DateTime('2010-11-12'); 
$dateTime->modify('last Monday'); 
echo $dateTime->format('Y-m-d'); 
2

使用as already answeredDateTime类或只是使用strtotime­Docs一次:

echo date('Y-m-d', strtotime("last Monday", strtotime("2010-11-12"))); 

或者更漂亮一字排开:

$date = strtotime("2010-11-12"); 
echo date('Y-m-d', strtotime("last Monday", $date)); 
2

中的strtotime函数可以接受Unix时间戳作为第二输入,用作相对计算中的现在时间。见文档here

相关问题