如何保存在日历控制显示中选择的日期和时间 [英] How to save date and time selected in a calender control display highlighted
本文介绍了如何保存在日历控制显示中选择的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我被要求开发一个在线影院预订的日历。
,其中每个日期有3个时段,如果在那个日期完成预订并且该字段应该具有红色背景的时间段意味着该日期的时间段被预订。
其他2个插槽应该是绿色背景。
请在这方面帮助我。
我用php和mysql开发。
以下是我的日历代码:
hello,
I am asked to develop a calender for online theater booking.
in which each date has 3 time slots and if any booking is done in that date and time slot that field should have red background means that time slot for that date is booked.
other 2 slots should be in green background.
please help me in this regards.
I am developing in php and mysql.
below is my code for calender:
<?php
error_reporting(0);
function build_calendar($month,$year,$dateArray) {
// Create array containing abbreviations of days of week.
$daysOfWeek = array('S','M','T','W','T','F','S');
// What is the first day of the month in question?
$firstDayOfMonth = mktime(0,0,0,$month,1,$year);
// How many days does this month contain?
$numberDays = date('t',$firstDayOfMonth);
// Retrieve some information about the first day of the
// month in question.
$dateComponents = getdate($firstDayOfMonth);
// What is the name of the month in question?
$monthName = $dateComponents['month'];
// What is the index value (0-6) of the first day of the
// month in question.
$dayOfWeek = $dateComponents['wday'];
// Create the table tag opener and day headers
$calendar = "<table class='calendar' border=1>";
$calendar .= "<caption>$monthName $year</caption>";
$calendar .= "<tr>";
// Create the calendar headers
foreach($daysOfWeek as $day) {
$calendar .= "<th class='header'>$day</th>";
}
// Create the rest of the calendar
// Initiate the day counter, starting with the 1st.
$currentDay = 1;
$calendar .= "</tr><tr>";
// The variable $dayOfWeek is used to
// ensure that the calendar
// display consists of exactly 7 columns.
if ($dayOfWeek > 0) {
$calendar .= "<td colspan='$dayOfWeek'> </td>";
}
$month = str_pad($month, 2, "0", STR_PAD_LEFT);
while ($currentDay <= $numberDays) {
// Seventh column (Saturday) reached. Start a new row.
if ($dayOfWeek == 7) {
$dayOfWeek = 0;
$calendar .= "</tr><tr>";
}
$currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT);
$date = "$year-$month-$currentDayRel";
$calendar .= "<td class='day' rel='$date'>$currentDay
<table border=1>
<tr><td bgcolor='green'>10am-1pm</td></tr>
<tr><td bgcolor='yellow'>1.30pm-4.30pm</td></tr>
<tr><td bgcolor='green'>5pm-8pm</td></tr>
</table>
</td>";
// Increment counters
$currentDay++;
$dayOfWeek++;
}
// Complete the row of the last week in month, if necessary
if ($dayOfWeek != 7) {
$remainingDays = 7 - $dayOfWeek;
$calendar .= "<td colspan='$remainingDays'> </td>";
}
$calendar .= "</tr>";
$calendar .= "</table>";
return $calendar;
}
$dateComponents = getdate();
$month = $dateComponents['mon'];
$year = $dateComponents['year'];
echo build_calendar($month,$year,$dateArray);
?>
推荐答案
月,
year,
dateArray){
// 创建包含星期几缩写的数组。
dateArray) { // Create array containing abbreviations of days of week.
这篇关于如何保存在日历控制显示中选择的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文