Mysql timestamps and php date ()

The mysql timestamp is in the standard format 2013-02-20 02:25:21, when I use the date ('H: i: s', $ date), I get the same invalid output 18:33:33 as I can get the right result? hours: minutes: seconds

+5
source share
5 answers

Tip: try with the MYSQL function DATE_FORMAT

SELECT DATE_FORMAT('2013-02-20 02:25:21', '%H:%i:%s');

if you want to do this only with php use strtotime

 date('H:i:s',strtotime('2013-02-20 02:25:21'));
+13
source

use this date('Y-m-d H:i:s',strtotime($date));

+14
source

It can help you.

date('H:i:s',strtotime($date));
+1
source

Try date('Y-m-d H:i:s',strtotime($date));

0
source

Try strptime()

strptime($date,"%H:%M:%S")
0
source

All Articles