How To Compare Two Dates in Codeigniter?
Dec 31, 2020
Hi Guys,
In this example,I will learn you how to compare two date in codeigniter.you can easy and simply compare to date in codeigniter.
Given two dates (date1 and date2) and the task is to compare the given dates. Comparing two dates in Codeigniter is simple when both the dates are in the same format but the problem arises when both dates are in a different format.
Example:
public function index(){
$date1=date_create("2020-04-12");
$date2=date_create("2020-12-12");
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");
}
Output:
+244 days
It will help you...
- Codeigniter 4 jQuery Client Side Form Validation Tutorial Example
- Codeigniter - Load more data on page scroll using jQuery and Ajax
- Codeigniter Image Crop With JQuery Croppie Example Tutorial
- CodeIgniter 4 jQuery Form Validation Example
- Codeigniter 4 Ajax Load More Data On Page Scroll With JQuery Tutorial
- CodeIgniter 4 - React JS CRUD with MySQL Example
- Codeigniter Create Bar Chart In PHP With Chart Js
- PHP Codeigniter 4 Google Bar & Line Charts Tutorial