I have a little issue with php and the time format. I tried to change the time using the date() function.
$time = date('g:i a',$time);
But the result I get for $time=15:30:30
is 3:30 am
The Ante meridiem stay stuck on AM event if it's the afternoon.
Thanks.
Try something like this:
$time = date("g:i a", strtotime("15:30:00"));
If taken from database My past codes were
// get the Shift times
$shiftArray=array();
$num=0;
$getShiftTimes=mysqli_query($link,"SELECT * FROM shift");
while ($returnShiftTimes = mysqli_fetch_array($getShiftTimes)){
$shiftArray[$num][0]=$returnShiftTimes['shift_id'];
$shiftArray[$num][1]=$returnShiftTimes['start_time'];
$shiftArray[$num][2]=$returnShiftTimes['end_time'];
$num++;
}
$time = date_format(date_create($shiftArray[0][1]), 'g:i A');
From 14:00:00 will return 2:00 PM
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