-2

I am fetching time and date from MYSQLi using php. For time I am getting default 24 hr format and for date I am recieving format of y/m/d.

  • I want to get time in 12 hr format.
  • I want to get date in d/m/y format.

How to do it in php ?

Aizaz hussain
  • 29
  • 1
  • 11

1 Answers1

0

In pure simple php, you can write as follow

Date

echo date('d/m/Y', strtotime($your_date));

Time

echo date('H:i', $your_time);

For the 12 hours, use

echo date('g:i A', $your_time);
Simone Cabrino
  • 901
  • 9
  • 24