0

So basically I'm not an expert in this and I cant find any solution, so what I wanted to do is adding a submitted date into global variable.

User will have to input the selected date range, and when User click the "submit" button, the data will appear.

<form method="post" action="<?php echo base_url() ?>index.php/overview/overall" class="form-inline">
<div class="input-group-addon">Please Choose the Date</div>
<input name="date-selector" type="text" class="form-control daterange" id="inlineFormInputGroup" placeholder="">
<input type="submit" name="submit" value="Submit" class="btn btn-primary">
</form>

and here's my controller if anyone needs it.

 public function overall(){
    $date = $this->input->post('date-selector');
    $start_date = date("Y-m-d", strtotime(substr($date, 0,10)));
    $end_date = date("Y-m-d", strtotime(substr($date, 13,22)));
    $data = $this->overview_model->overall_data($start_date,$end_date);
}

How can I create a variable for the "date" to be global, so I can use that date variable in multiple function in controller? Thanks

xharmas
  • 43
  • 2
  • 8
  • Please follow the below link for help : http://stackoverflow.com/questions/17013397/code-igniter-best-place-to-declare-global-variable – Ranvir S. May 09 '17 at 05:30
  • @RanvirSingh the thing is, user I wanted user to insert the date, how can I configure that? – xharmas May 09 '17 at 07:12

1 Answers1

1

Define Global variable "$_date" in constants.php (Location: application\config) so you can use it in model, view, and controller too.

Preetham Hegde
  • 839
  • 2
  • 13
  • 24