How do I return the previous Sunday from 7 days ago using PHP date()?
问题 Here is what I have so far: $date = date('Y-m-d h:i:s', strtotime('-7 days')); $start = date('Y-m-d h:i:s', strtotime($date,'previous Sunday')); When outputting $start, it returns: 1969-12-31 06:00:00 What am I doing wrong? 回答1: $date needs to e a timestamp $date = strtotime('-7 days'); $start = date('Y-m-d h:i:s', strtotime('previous Sunday',$date)); 回答2: You have the arguments the wrong way round: date('Y-m-d h:i:s', strtotime('previous Sunday', $date)); Edit : Furthermore, you have made