I need to remove the seconds off of a returned time value. I get
12:00:00
I want
12:00pm
I tried using date()
but it kept returning the time as 1:00am for everything.
echo date('g:ia', $timestamp);
If you only need to remove seconds (not PM needed), you can use both MYSQL or php:
MYSQL:
SELECT SUBSTRING(SEC_TO_TIME(seconds), 1, 5);
PHP:
$cleantime=substr($time,0,-3);
both will strip off seconds and keep hours and minutes
thanks to Jahanzeb for enhancing the PHP version to support also > 99 hours
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