In this tutorial, We will learn how to convert date format in the Codeigniter 3 framework. we will change the date format yyyy-mm-dd (Y-m-d) to dd-mm-yyyy (d-m-Y). 



Example:

<?php

$sampleDate = '2021-01-02';
$convertDate = date("d-m-Y", strtotime($sampleDate));
  
print_r($convertDate);


Output:

01-02-2021