The date() function returns the current server timestamp and you can format it according to a set of parameters. The syntax is date(format,timestamp); If timestamp is not given, current date and time is assumed.
Here are some date() function formats for your reference.
Usually, the format that we used to save time in our table is H:i:s in which the result is something like this: 14:00:00 which is in 24 hour format. So to make your time more readable to users, you need to format it in 12 hour format.
Code
<?php
$time="19:04:28";
echo date('h:i:s A', strtotime($time);
?>
Output
No comments:
Post a Comment