Wednesday, January 20, 2016

PHP DATE AND TIME FORMAT: Display Time in 12 Hour Format from 24 Hour Format

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


PHP DATE AND TIME FORMAT: Display Time in 12 Hour Format from 24 Hour Format

PHP DATE AND TIME FORMAT: Display Time in 12 Hour Format from 24 Hour Format Rating: 4.5 Diposkan Oleh: Emoblazz

0 comments:

Post a Comment