AM PM Not Showing Correctly In PHP / Codeigniter

Date Format In PHP/ Codeigniter not showing Correctly means AM and PM mismatching, No worries. Just check below step you can easily find out what is the mistake you are doing.



1st way to fix the problem

Step-1: If you are using the table column as “TIMESTAMP ” then You have to use the below

$the_date = date(“m-d-Y H:i A”, strtotime($row->date_column));

Here H is capital means it will fetch the data as 24 hours format.



2nd way to fix the error

Step-1: If you are using the Column Type as “datetime” then When you are inserting data in the table make sure you are inserting the below format

date(“Y-m-d H:i:s”);  // Here I made it as 24hours format by using capital H.

Then it will work fines