大家好,我正在用我的日历构建。
我正在尝试为我的日历获取当前月份的前后日期。实际上日历已经在工作,但它与我笔记本电脑的时间不同。
我是否必须更改此代码中的某些内容?
$month = 9;
$year = 2013;
// calculate the number of days in the current month
$day_count = cal_days_in_month(CAL_GREGORIAN, $month, $year);
// get number of days for the next month
$pre_days = (6 - (date('w', mktime(0, 0, 0, $month, $day_count, $year))));
// get number of days after the month
$post_days = date('w', mktime(0, 0, 0, $month, 1, $year));
然后我正在循环显示日期..
echo "<div id='cal_wrapper'>";
echo "<div class='title_bar'>";
echo "<div class='prev_month'></div>";
echo "<div class='show_month'></div>";
echo "<div class='next_month'></div>";
echo "</div>"; // end title bar
echo "<div class='week_days'>";
foreach($weekDaysArr as $value)
{
echo "<div class='days_of_week'>".$value."</div>";
}
echo "<div class='clear'></div>";
echo "</div>"; // end week days
// Previous Month Filler
if($pre_days != 0) {
for($i = 1; $i <= $pre_days; $i++)
{
echo "<div class='non_cal_days'></div>";
}
}
// Current day of the month filler
if($day_count != 0 )
{
for($x = 1; $x <= $day_count; $x++)
{
echo "<div class='cal_days'>";
echo "<div class='day_header'>".$x."</div>";
echo "</div>";
}
}
// Current day of the month filler
if($post_days != 0 )
{
for($y = 1; $y <= $post_days; $y++)
{
echo "<div class='non_cal_days'></div>";
}
}
echo "</div>"; // end calendar wrapper