Date Format PHP: retrieve result date short by day, month and year in PHP
Fetch result from MySQL table, where date short by day or month or year. To format date field form database field and gets all result to display in a table page or a single page.
In PHP DATE FORMAT allow formatting date when you set Date Format in your retrieve query. That’s like select data from MySQL table where(‘DATE_FORMAT(column_date,”%Y”).
It fetches result and returns all selected values jump to DATE FORMAT in your web application. It will be helpful when, you get the result from the database by the only day, month, year. If you set your database date column data type date/time so, do not think more. DATE FORMAT fetching all result from MySQL date column short by day or month or year.
I have an example for you. You can follow the example and try it in your web application and get success in your project.
For Example:
<?php public function getResult($start_month,$end_month,$select_year){ $qry=$this->db->select('*')->from('table_name') ->where("DATE_FORMAT(column_date,'%m') BETWEEN '$start_month' AND '$end_month' ") ->where('DATE_FORMAT(column_date,"%Y")',$select_year)->get()->result(); return $qry; } ?>