Search code examples
cakephpjalali-calendar

compare jalali dates in cakephp


I need to get users which their payment_time is between startDate and endDate in cakePHP.dates are in jalali format :

۱۳۹۷ - ۰۱ - ۱۴

and my controller is as follows:

public function search(){

    if ($this->request->is('post')){
        if(!empty($this->request->data['User']['start_date'])&&
           !empty($this->request->data['User']['end_date'])){

           $start_date =  $this->request->data['User']['start_date'] ;
           $end_date = $this->request->data['User']['end_date'];
           $this->Paginator->settings['conditions']['AND'] = array(
                                      'User.payment_time >= ' => $start_date,
                                      'User.payment_time <= ' => $end_date);

           $this->set('users', $this->Paginator->paginate());
        }
}

But users is view page is null. Is this method can help for jalali dates?


Solution

  • Simply make a snippet to replace the Urdu/English numerals with English/Urdu numerals then parse the dates.