1

I need to select current date from database in mm/dd/yyyy format..But php curdate() function returns date format in yyyy-mm-dd as default..How could I resolve this issue.?

My model function is:

public function get_cat($category)
    {
        $this->db->select('*');
        if($category!='')
        {
            $this->db->like('Category',$category,'both');
            $this->db->from('tbl_job');
            $this->db->where('Expiry_date >=','DATE(CURDATE())',FALSE);
            $result = $this->db->get();
        }
        return $result->result();
    }
Hanan Ashraf
  • 518
  • 3
  • 7
  • 21

2 Answers2

2

Use DATE_FORMAT to format the date

DATE_FORMAT(curdate(), '%m/%d/%Y')
Thamilhan
  • 13,040
  • 5
  • 37
  • 59
0

use Str_to_date

Str_to_date(Expiry_date,'%m/%d/%Y')

Try this code :-

$this->db->where('Str_to_date(Expiry_date,'%m/%d/%Y') >=','DATE(CURDATE())',FALSE);
Abhishek Sharma
  • 6,689
  • 1
  • 14
  • 20