I'm updating some very old PHP (3 I think) to PHP 5.6 and am having problems getting the time formatted for old posts. The date is stored in the MySQL database and I can retrieve that fine - but the old code delivers a null output. Everything I read about formatting seems to assume I want the current date. I want to 2012-11-09 14:17:18 to just read 2012-11-09 14:17
Here is the original code from the ancient version of the phorum:
$datestamp = date_format($head_row["datestamp"]);
echo $datestamp
but that produces an empty nothingness, so I changed it to:
$datestamp = ($head_row["datestamp"]);
and that gives me the whole saved datestamp. How do I cut off the seconds?
I think what you are looking for is strtotime.
$datestamp = date('Y-m-d H:i', strtotime($head_row["datestamp"]));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With