S
S
Schoolboy.2015-09-30 21:03:55
PHP
Schoolboy., 2015-09-30 21:03:55

How to format date and time from mysql to php?

It is necessary to turn the received date and time "2015-12-12 12:12:12" into "12/12/2015 at 12:12". Tried like this date('d.m.Y H:i', $x[0]['time']), but there are completely different date, time, and even an incomprehensible indent from above.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivanq, 2015-09-30
@viphorizon

echo date("d-m-Y H:i:s", strtotime("2015-12-12 12:12:12"));

R
Rsa97, 2015-09-30
@Rsa97

And who's stopping you from getting the date immediately in the right format via DATE_FORMAT() ?
so or

$date = date_create($x[0]['time']);
echo date_format($date, 'd.m.Y H:i');

P
patch1, 2015-09-30
@patch1

$new_time = str_replace("-", ".", $x[0]['time']);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question