Recently I have created robotic mailing system for my client. But when it needed to convert a bunch of 24 hour times to 12 hours, the times were in different formats but I needed them in a format that was easily human readable. This function will convert a twenty four hour time to twelve hour time. Feel free to modify it to your own needs.
Code is here:
[php]
<?php
/**
*
* @convert 24 hour time to 12 hour
*
* @param string $time
*
* @return string
*
*/
function twentyfourToTwelve($time)
{
return date('g:i:sa', strtotime($time));
}
/*** Example usage ***/
echo twentyfourToTwelve('15:33:56').'<br />';
echo twentyfourToTwelve('15:33').'<br />';
echo twentyfourToTwelve('15.12').'<br />';
echo twentyfourToTwelve('2:33:56').'<br />';
echo twentyfourToTwelve('15:33').'<br />';
?>
[/php]
Very interesting information!Perfect just what I was searching for!
ReplyDeleteHey! I know this is kinda off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having difficulty finding one? Thanks a lot!
ReplyDeleteI simply want to say I'm new to weblog and absolutely loved this page. Probably I’m want to bookmark your blog . You absolutely come with tremendous articles and reviews. Thanks a bunch for sharing with us your blog site.
ReplyDelete