弹出窗口将在给定时间段内显示

I've created a popup (on windows onload). I want it to be displayed only from 18th to 25th on each month. How could I do that? I'm using Codeigniter.

model:

public function getunpaidtodate() {

    $query = $this->db->query("SELECT spp.studentid, si.firstname, 
                                      si.lastname 
                                FROM `studentpaymentplan` spp
                                    JOIN studentinfo si ON spp.studentid=si.studentid 
                                GROUP BY spp.studentid");     
    return $query->result();  
}

controller:

$data['result'] = $this->mdl_studentinfo->getunpaidtodate();

view file:

<div class="alert" id='alert'>
      <span class="closebtn" id="test" onclick="this.parentElement.style.display='none';">&times;</span>
      <strong><?php  echo ' '; echo $row->firstname; echo ' '; echo $row->lastname; ?>

        <table>
        <tr>
        </tr>
        <?php foreach($result  as $r): ?>
        <tr><?php echo $r->firstname; ?>
            <?php echo $r->lastname; ?>
        </tr><br>
        <?php endforeach; ?>
        </table>
       <br></strong> pay soon !
</div>

Thanks !

<script>

$(function() {

 var now = new Date();
        if (now.getDate() >= 18 && now.getDate() <= 25) {
            run_pop_up_function();
        }
});

</script>

I updated the above script and added id='alert' for the div in view

<script>
$(document).ready(function(){
     var now = new Date()
     if(now.getDate() <= 19 ){
    $(window).load(function(){
        // alert("Page loaded.");
         $('#alert').hide();
    });
 }
});
</script>