2013-04-08 52 views
-1

1你好这个代码会告诉你只有年份+ 1的日期,当用户打开日历,但我需要什么代码有年+ 2, 年+ 3 ...日历?请注明您是否还需要家长和孩子文件的代码PHP日历多年

<?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(); 
      } 
     }); 
+3

我实际上看不到你输出什么东西。包含所有您遇到问题的代码可能会很有帮助,而不仅仅是其中的一部分。 – 2013-04-08 15:08:07

+0

ok会发送其余的代码 – user2257823 2013-04-08 15:15:48

+0

您添加的代码不使用上面设置的任何PHP变量? – 2013-04-09 07:16:31

回答

0

见PHP函数strtotimehttp://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"; 
?>