PHP日历多年

时间:2013-04-08 15:03:43

标签: php

1你好这个代码只会显示用户打开日历时的当前年份+ 1,但是我需要用什么代码来获得年份+ 2, 年+ 3 ......日历?请指定是否还需要父文件和子文件的代码

<?php
include ("access.php");
include ("header.php");
include("../includes/conf.class.php");
include("../includes/admin.class.php");

date_default_timezone_set($bsiCore->config['conf_hotel_timezone']);    

$monthNames = array(
    "January"   => 1, 
    "February"  => 2, 
    "March"     => 3, 
    "April"     => 4,
    "May"       => 5,     
    "June"      => 6, 
    "July"      => 7, 
    "August"    => 8, 
    "September" => 9, 
    "October"   => 10,
    "November"  => 11, 
    "December"  => 12
);

if (!isset($_REQUEST["year"])) $_REQUEST["year"] = 2012;

$time          = time();
$today         = date("Y/n/j", $time);
$current_month = date("n", $time);
$current_year  = date("Y", $time);
$cMonth        = 1;
$cYear         = $_REQUEST["year"];
$prev_year     = $cYear;
$next_year     = $cYear;
$prev_month    = $cMonth-1;
$next_month    = $cMonth+1;

if ($prev_month == 0 ) {
    $prev_month = 12;
    $prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
    $next_month = 1;
    $next_year = $cYear + 1;
}
?>
   <script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
    $('#year').change(function(){
            window.location = 'calendar_view.php?year='+$('#year').val();
        }); 

        $('#roomtype').change(function(){
            if($('#roomtype').val() != 0){
                capacityConmboShow();
            $('#submitButton').show();
            }else{
                $('#submitButton').hide(); 
            }
        });

1 个答案:

答案 0 :(得分:0)

请参阅PHP函数strtotime http://www.php.net/manual/en/function.strtotime.php。它可以为你做所有的计算。

<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?>