首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用特定日期

禁用特定日期
EN

Stack Overflow用户
提问于 2020-10-05 16:45:13
回答 1查看 34关注 0票数 0

所以我想禁用以月为单位的特定日期,这是我在控制器中名为"jurnal.php“的函数

代码语言:javascript
复制
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("first day of $month $currentYear"));
            if ($r == 1) {
                $hasilmax = 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号就停用了。如何让这一切成为现实?

EN

回答 1

Stack Overflow用户

发布于 2020-10-05 18:28:59

如果您想限制前端(extjs)的日期字段中的天数,可以使用日期字段的setDisabledDates方法。

例如:要禁用10月5日和6日,请使用:datefield.setDisabledDates(["10/05/2003", "10/06/2003"])

有关更多详细信息,请查看link

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64205269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档