-1

A few minutes ago I discovered that the forum on my site will incorrectly display AM and PM in the dates. The rest of the time displays correctly and the date.

This is what I have been using for the date times

$date = $row['post_date'];
$realDate = date('m/d/Y', $date);
$realTime = date('H:i:A', $date);
$now = date("m/d/Y H:i:A");

2 Answers2

0

The problem is that you are getting $date from database. so you need to set default timezone to your database as well. you can try

SELECT now()

to check whether you are getting the correct time. If not then you need to set a timezone for your database by doing below query.

SET GLOBAL time_zone = '+5:30';  //this is temp if you restart server this will be gone.

in the place of +5:30 enter you timezone.

here is the link for more details.

danish-khan-I
  • 776
  • 6
  • 15
0

Use this format to display DATETIME in this fromat like 2019-08-03 11:31:22 AM

if you use small a in date format it show am/pm in small letter.

date('Y-m-d H:i:s A');

Sandeep K.
  • 759
  • 6
  • 18