2016-04-14 23 views
1

私はこのカレンダーを日曜日ではなく月曜日に始める方法を探していました。私の週カレンダーを日曜日ではなく月曜日から始める

私は$ firstDayArray ['wday'] - 1のようなさまざまなことを試してきましたが、1つ余分な空白が作成され、カレンダーは1日スキップされます。

どんな種類の助けがいいですか? P.s私は大きな騒ぎですが、練習しようとしています。私はこの偉大なサイトのほぼあらゆる場所を検索して答えを出しています。haventはそれをまだ見つけました。

<?php 
define("ADAY", (60*60*24)); 
if ((!isset($_POST['month'])) || (!isset($_POST['year']))){ 
    $nowArray =getdate(); 
    $month = $nowArray['mon']; 
    $year = $nowArray['year']; 
} else { 
    $month = $_POST['month']; 
    $year = $_POST['year']; 
} 
$start = mktime (12, 0, 0, $month, 1, $year); 
$firstDayArray = getdate($start); 
?> 
<!DOCTYPE html> 

<html> 
<head> 
<title><?php echo "Calendar:".$firstDayArray['month']." 
".$firstDayArray['year']; ?> 
</title> 
<meta charset="utf-8"> 
<meta lang="da"> 
<link type="text/css" rel="stylesheet" href="calendar_style.css"> 
</head> 
<body> 
<form align="center" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 

<select name="month"> 
<?php 
$months = Array("Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", 
"September", "Oktober", "November", "December"); 
for ($x=1; $x <= count($months); $x++) { 
    echo"<option value=\"$x\""; 
    if ($x == $month) { 
     echo " selected"; 
    } 
    echo ">" .$months[$x-1]."</option>"; 
} 
?> 
</select> 
<select name="year"> 
<?php 
for ($x=2016; $x<=2018; $x++) { 
    echo "<option"; 
    if ($x == $year) { 
     echo " selected"; 
    } 
    echo ">$x</option>"; 
} 
?> 
</select> 
<button type="submit" name="submit" value="submit">Gå til måned</button> 

</form> 
<br> 

<?php 
$days = Array("Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"); 
echo "<table><tr>\n"; 
foreach ($days as $day) { 
    echo "<th>" .$day."</th>\n"; 
} 
for ($count=0; $count < (6*7); $count++) { 
    $dayArray = getdate($start); 
    if (($count % 7) == 0) { 
     if ($dayArray['mon'] != $month) { 
      break; 
     } else { 
      echo "</tr><tr>\n"; 
     } 
    } 
    if ($count < $firstDayArray['wday'] || $dayArray['mon'] != $month) { 
     echo "<td>&nbsp;</td>\n"; 
    } else { 
     echo "<td>" .$dayArray['mday']."</td>\n"; 
     $start += ADAY; 
    } 
} 
echo "</tr></table>"; 
?> 
</body> 
</html> 
+0

あなたが設定した後に ' display:block'、これらの要素を整列させるにはmargin:0 autoを設定する必要があります –

答えて

0

代わりにブートストラップ3を入力として使用できます。 あなたは次のことを試してみてください(太陽が座っていた)この

<div class="container"> 
<div class="col-sm-6" style="height:130px;"> 
    <div class="form-group"> 
     <div class='input-group date' id='datetimepicker11'> 
      <input type='text' class="form-control" /> 
      <span class="input-group-addon"> 
       <span class="glyphicon glyphicon-calendar"> 
       </span> 
      </span> 
     </div> 
    </div> 
</div> 
<script type="text/javascript"> 
    $(function() { 
     $('#datetimepicker11').datetimepicker({ 
      daysOfWeekDisabled: [0, 6] 
     }); 
    }); 
</script> 

0

として https://eonasdan.github.io/bootstrap-datetimepicker/

を数週間の日数を無効にすることができ、それが動作します:

<?php 
$days = Array("Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"); 
echo "<table><tr>\n"; 
foreach ($days as $day) { 
    echo "<th>" .$day."</th>\n"; 
} 
for ($count=0; $count < (6*7); $count++) { 
    $dayArray = getdate($start); 
    if ((($count + 7) % 7) == 0) { 
     if ($dayArray['mon'] != $month) { 
      break; 
     } else { 
      echo "</tr><tr>\n"; 
     } 
    } 
    if ($count < ($firstDayArray['wday'] + 6) || $dayArray['mon'] != $month) { 
     echo "<td>&nbsp;</td>\n"; 
    } else { 
     echo "<td>" .$dayArray['mday']."</td>\n"; 
     $start += ADAY; 
    } 
} 
echo "</tr></table>"; 
?> 
関連する問題