问题描述
所以我想禁用特定月份的日期,这是我在控制器中的函数“ jurnal.PHP”
function jurnal_harian_form() {
setlocale(LC_ALL,"US");
echo "<h3 id='title'>Jurnal Harian :: Daftar SKP :: Form Jurnal Harian</h3>";
$_GET['nip'] = ($_SESSION['NIP']);
$data_profil_pegawai = $this->jurnal_mdl->get_data_statistik_Jabatan();
$harilibur = $this->jurnal_mdl->GetHariLibur();
$currentYear = date("Y");
$currentDay = date("d");
$month = strftime("%B");
$min = date('Y-m-d',strtotime("$month $currentYear + 14 days"));
$Now = date('Y-m-d');
$r =0;
for ($i=1; $i < 6 ; $i++) {
$gg = date('Y-m-d',strtotime("$i $month $currentYear"));
$issun = date('w',strtotime("$gg"));
if ($issun == '6' || $issun == '0') {
$min = date('Y-m-d',strtotime("$min +1 days"));
$r++;
}
}
$hasilmin = '';
$hasilmax = '';
if($Now >= $min){
$hasilmin = date('Y-m-d',strtotime("first day of $month $currentYear"));
if ($r == 1) {
$hasilmax = date('Y-m-d',strtotime("$month $currentYear +1 month +6 days"));
} elseif($r == 2) {
$hasilmax = date('Y-m-d',strtotime("$month $currentYear +14 days"));
}else{
$hasilmax = date('Y-m-d',strtotime("$month $currentYear +1 month +5 days"));
}
}else if($Now == $min){
$hasilmin = date('Y-m-d',strtotime("$month $currentYear +5 days"));
} elseif($r == 2) {
$hasilmax = date('Y-m-d',strtotime("$month $currentYear +6 days"));
}else{
$hasilmax = date('Y-m-d',strtotime("$month $currentYear +4 days"));
}
}else{
$hasilmin = date('Y-m-d',strtotime("first day of $month $currentYear "));
if ($r == 1) {
$hasilmax = date('Y-m-d',strtotime("$month $currentYear +5 days"));
}
elseif($r == 2 && $currentDay <= 15) {
$hasilmax = date('Y-m-d',strtotime("$month $currentYear +14 days"));
}
elseif($r == 2 && $currentDay >= 15) {
$hasilmax = date('Y-m-d',strtotime("$Now +14 days"));
}
else{
$hasilmax = date('Y-m-d',strtotime("$month $currentYear +4 days"));
}
}
$data = array(
"html_store" => $this->get_store_form_tambah_jurnal(),"pegawai" => $data_profil_pegawai,"harilibur" => $harilibur,"minvalue" => $hasilmin,"maxvalue" => $hasilmax
);
$this->load->view('jurnal/grid_jurnal_harian2',$data);
}
我想制作,当月份仍在1号到15号时,则禁用该月的16号到月末,但是如果已经在16号,则禁用1号到15号。如何做到这一点?
解决方法
如果要在前端(extjs)的日期字段中限制天数,可以使用日期字段的setDisabledDates
方法。
例如:要禁用10月5日和6日,请使用:datefield.setDisabledDates(["10/05/2003","10/06/2003"])
有关更多详细信息,请查看link