// 将目前的时间戳值放入一数组内 $strdate = '2014-02-03'; $desDate = strtotime($strdate); //var_dump($desDate);
$timestamp = time(); //echo "\noriginalDate:".date('Y-m-d',time())."\n"; echo "\noriginalDate:".date('Y-m-d',$desDate)."\n";
//$date_time_array = getdate($timestamp); $date_time_array = getdate($desDate); $hours = $date_time_array["hours"]; $minutes = $date_time_array["minutes"]; $seconds = $date_time_array["seconds"]; $month = $date_time_array["mon"]; $day = $date_time_array["mday"]; $year = $date_time_array["year"]; // 用mktime()函数重新产生Unix时间戳值减7天 $timestamp = mktime($hours, $minutes, $seconds, $month, $day-7, $year); echo "\naddSevenDate:".date('Y-m-d',$timestamp)."\n";
echo "\n------\n"; $yestertime = date ( 'Y-m-d', strtotime("-7 day",$desDate) ); echo "maethod2:".$yestertime;
|
请发表评论