Is it possible to save/insert time data with 12hour format using input time?.
instead of having 13:00 as 1:00 PM i want to save it as 1:00 PM. the type of field of the column is var char.
Is it possible to save/insert time data with 12hour format using input time?.
instead of having 13:00 as 1:00 PM i want to save it as 1:00 PM. the type of field of the column is var char.
You first have to create a date variable and then convert that to the desired format. Assuming your input field name is hour the following should work:
$date=date_create($_GET['hour']); echo date_format($date,"h:i:s a");
For more information about this look at the date page in here: http://php.net/manual/en/function.date.php
If you have varchar format in time you can do this...
<?php
if(isset($_POST['submitform'])){
$formattedtime = date('h:i A', strtotime($_POST['time']));
echo $formattedtime;exit;
}
?>
<form action="" method="post" >
<input type="time" name="time" />
<input type="submit" name="submitform">
</form>
Save the formattedtime variable to your database