Php 倒数几个月
我是新来的,有没有倒24个月而不是2年的月脚本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
<?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; ?>'
});
});