各位大大,$date2=date('d/m/Y');  得到当前年月日。如果今天是3月26号,那么三个月的期限就是6月26号。(不论一个月30还是31天,按照月算)1,怎样写可以算出三个月是多少天呢?2,如果得到天数以后,$XXXX=天数, 每过一天,天数就自动减去一天,请问如何写呢?谢谢各位

解决方案 »

  1.   


    <?php 
    $startdate=strtotime(date("Y-m-d"));
    $enddate=strtotime(date("Y-m-d",strtotime(" +3 month")));
    $days=round(($enddate-$startdate)/3600/24) ;
    echo $days;     //days为得到的天数;
    ?>
      

  2.   

    上面没写好 <?php 
    $startdate=strtotime("2010-3-26"); //开始日期
    $enddate=strtotime("2010-6-26"); //结束日期
    $days=round(($enddate-$startdate)/3600/24) ; //开始到结束一共有几天$date=strtotime(date("Y-m-d")); //今天
    $d=round(($date-$startdate)/3600/24) ; //开始日期到今天一共有几天echo $days -$d; //
    ?>
      

  3.   

    楼上的大大这些代码之前 要先知道今天的日期呀   $startdate=strtotime("2010-3-26"); 这不是自动查今天的日期呀 查到今天的日期后, 要自动算出三个月后结束的那一天是几月几号,然后算出三个月是多少天然后每过一天,总数就减一天。
    举个例子,就像倒计时一样。期限是三个月。过一天就减一天。谢谢
      

  4.   

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <?php
    $end=strtotime("2010-4-26");
    $start=strtotime(date("Y-m-d"));  
    $n=ceil(($end-$start)/(60*60*24));
    echo "离 2010-4-26 还有 $n 天";
    ?> 
      

  5.   

    楼上的各位,
    $xxxxxx=26/03/2010怎样写才能让$yyyyyy=$xxxxxx+三个月呀
    也就是让$yyyyyy=26/06/2010谢谢各位