I have this code:
<input class="meting" name="meetingtime" value="<?php echo $_POST['meetingtime'] ?>" type="time"/>
<?php
$time = $_POST['meetingtime'];
echo $time; // the output of this is only the numbers
?>
How can I get the AM/PM values in PHP?
PHP has a build in function to do that.
$time = $_POST['meetingtime'];
echo date("g:i a", $time);
// 10:22 AM
If you get a fatal error try adding strtotime()
to the time.
Fatal error: Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int...
$time = $_POST['meetingtime'];
echo date("g:i a", strtotime($time));
// 10:22 AM