Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 倒数几个月_Php_Jquery_Jquery Ui - Fatal编程技术网

Php 倒数几个月

Php 倒数几个月,php,jquery,jquery-ui,Php,Jquery,Jquery Ui,我是新来的,有没有倒24个月而不是2年的月脚本 <?php $curYear = date(Y); $minYear = $curYear - 2; ?> <script type="text/javascript"> jQuery(function($) { $('#child_birthday').datepicker({ changeMon

我是新来的,有没有倒24个月而不是2年的月脚本

    <?php
        $curYear = date(Y);
        $minYear = $curYear - 2;
     ?>

    <script type="text/javascript">
        jQuery(function($) {
            $('#child_birthday').datepicker({
              changeMonth: true,
              changeYear: true,
              yearRange: '<?php echo $minYear; ?>:<?php echo $curYear; ?>'
            });
        });
    </script>

jQuery(函数($){
$('child#u birth')。日期选择器({
变化月:对,
变化年:是的,
年份范围:':'
});
});

要限制用户选择2013年9月之前的日期,请使用
minDate
选项


jQuery(函数($){
$('child#u birth')。日期选择器({
变化月:对,
变化年:是的,
minDate:新日期(,-1,1),
年份范围:':'
});
});

顺便说一句,您可以用javascript直接计算当前年份和月份,因此无需用php计算并将结果传递给javascript。

Hi如果我使用2年,日历允许选择一个可以追溯到2013年初的日期。如果我能用24个月,那么它就不允许在2013年9月之前返回。
 <?php
    $curYear = date('Y');
    $minYear = $curYear - 2;
    $curMonth = date('j');
 ?>

    jQuery(function($) {
        $('#child_birthday').datepicker({
          changeMonth: true,
          changeYear: true,
          minDate: new Date(<?php echo $minYear; ?>, <?php echo $curMonth ?> - 1, 1),
          yearRange: '<?php echo $minYear; ?>:<?php echo $curYear; ?>'
        });
    });