Finding Current Periode

I would like to select current academic year period based on current date.

Current date: 30 June 2014, the available academic year period was 1 July 2013 - 30 June 2014, but the return value ($last_id) was 0, it should be 1. The $current_date was not match with the if condition, the process went to die('stop@5…) which displayed ‘stop@5 0 2014-06-30=1404079200 2013-07-01=1372629600 2014-06-30=1404079200’

I don’t know why.

Here is my code:

public function getCurrentAcadYear(){



     $LastRecord=$this->find(array('order'=>'id DESC'));


     if($LastRecord<>NULL){ //jika tidak kosong


          while ($last_id>0){


               $_begin=date('Y-m-d', strtotime(str_replace(",", "", $_begin)));                    



               $_end=date('Y-m-d', strtotime(str_replace(",", "", $_end)));


               if(($_begin_UNIX<=$current_date) and ($current_date<=$_end_UNIX)){

                        return $last_id;


               else {





          die('stop@5 '.$last_id.' '.$current_date.'='.$current_date_UNIX.' '.$_begin.'='.$_begin_UNIX.'       '.$_end.'='.$_end_UNIX);



          echo 'Tidak ada tahun akademik yg dapat dipilih';