日期和今天的PHP差异(显示周)

Ok, here is my problem. Instead of measuring 7 days in seconds, I want to count how many weeks (Sunday Through Saturday) there are from date #1 to today.

PHP

$today1 = date("Y-m-d");  

$diff = strtotime($date1,0) - strtotime($today1,0);
echo (floor($diff / 604800)); 

If you're counting in seconds, why use date() when you can use time() instead- it gives out the numeric time signature of your current time, making calculations such as this much easier.

Using seconds is fine, perhaps try something like this:

$date1  = "2012-12-25";
$today1 = time();

$diff = strtotime($date1) - $today1;
if($diff < 604800) {
  $week = "this week";
} else {
  $week = (floor($diff / 604800) == 1) 
    ? floor($diff / 604800) . " week away" : floor($diff / 604800) . " weeks away";
}

echo $week;