how curdate function could return date in mm/dd/yyyy format php

故事扮演 提交于 2021-01-28 23:01:55

问题


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();
    }

回答1:


Use DATE_FORMAT to format the date

DATE_FORMAT(curdate(), '%m/%d/%Y')



回答2:


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);


来源:https://stackoverflow.com/questions/33991851/how-curdate-function-could-return-date-in-mm-dd-yyyy-format-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!