How to (Easily) Change Date Format in codeigniter?

Today, We want to share with you date format codeigniter.In this post we will show you get only date from datetime in codeigniter, hear for time ago in codeigniter we will give you demo and example for implement.In this post, we will learn about Date Formats In PHP Codeigniter with an example.

How to change date format in PHP Codeigniter?

You can use strtotime() and date() of php as :

$join_dt = $row->start_date;
$newDate = date("d-m-Y", strtotime($join_dt));

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



Helper Function:

    function setDtFormatLive($format = 'd-m-Y', $join_dt)
        return date($format, strtotime($join_dt));

Use Helper Function:

	echo setDtFormatLive('d-m-Y',$user->created_at) 


$dob = "2021-03-08";
echo date("d-m-Y", strtotime($dob));
//Results date

I hope you get an idea about Display date formats as DD MM YYYY in Codeigniter.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Also Read This 👉   Eloquent Order By Relation Column in Laravel