function reday($d){
 return date("Y-m-d", time()-60*60*24*$d);
}
echo reday(10);//10天前

解决方案 »

  1.   

    You could use the function: "strtotime()",as your question ,the example like
    $youwantvalue=strtotime("now - 100 days 4 hours 22 minutes ");
    print(date($yourwantvalue));
    lucky for U!~
      

  2.   

    完善
    keaizhong(可爱钟) 的:
    function reday($d,$hour,$min, $sec,$mon,$day,$year){
     return date("Y-m-d", mktime($hour,$min, $sec,$mon,$day,$year)-60*60*24*$d);
    }
      

  3.   

    回复人: lantersen(朗特森) ( ) 信誉:100  2005-03-18 08:42:00  得分: 0  
     
     
       You could use the function: "strtotime()",as your question ,the example like
    $youwantvalue=strtotime("now - 100 days 4 hours 22 minutes ");
    print(date($yourwantvalue));
    lucky for U!~  
     
    COOL!!!推荐用这种
      

  4.   

    //得到$year年,$mon月,$day日,$hour小时,$min分,$sec秒前(后)的unix时间戳
    function get_new_time($year,$mon,$day,$hour,$min, $sec,$flag="before"){
    $year=empty($year) ? "" : "$year years";
    $mon=empty($mon) ? "" : "$mon months";
    $day=empty($day) ? "" : "$day days";
    $hour=empty($hour) ? "" : "$hour hours";
    $min=empty($min) ? "" : "$min minutes";
    $sec=empty($sec) ? "" : "$sec seconds";


    $flag=($flag!="before") ? "+" : "-";
    echo "now $flag $year $mon $day $hour $min $sec<br>";
      return strtotime("now $flag$year $flag$mon $flag$day $flag$hour $flag$min $flag$sec");
    }
      

  5.   

    不好意思,重写一下:)
    //得到$year年,$mon月,$day日,$hour小时,$min分,$sec秒前(后)的unix时间戳
    function get_new_time($year,$mon,$day,$hour,$min, $sec,$flag="before"){
      $year=empty($year) ? "" : "$year years";
      $mon=empty($mon) ? "" : "$mon months";
      $day=empty($day) ? "" : "$day days";
      $hour=empty($hour) ? "" : "$hour hours";
      $min=empty($min) ? "" : "$min minutes";
      $sec=empty($sec) ? "" : "$sec seconds";
      $flag=($flag!="before") ? "+" : "-";  return strtotime("now $flag$year $flag$mon $flag$day $flag$hour $flag$min $flag$sec");
    }