{"id":3042,"date":"2011-12-05T00:02:23","date_gmt":"2011-12-05T06:02:23","guid":{"rendered":"http:\/\/humairahmed.com\/blog\/?p=3042"},"modified":"2012-01-04T23:15:53","modified_gmt":"2012-01-05T05:15:53","slug":"perl-converting-the-time-from-24-hr-to-12-hr-format","status":"publish","type":"post","link":"https:\/\/humairahmed.com\/blog\/?p=3042","title":{"rendered":"Perl &#8211; Converting the Time from 24 hr to 12 hr Format"},"content":{"rendered":"<div class=\"twttr_buttons\"><div class=\"twttr_twitter\">\n\t\t\t\t\t<a href=\"http:\/\/twitter.com\/share?text=Perl+-+Converting+the+Time+from+24+hr+to+12+hr+Format\" class=\"twitter-share-button\" data-via=\"\" data-hashtags=\"\"  data-size=\"default\" data-url=\"https:\/\/humairahmed.com\/blog\/?p=3042\"  data-related=\"\" target=\"_blank\">Tweet<\/a>\n\t\t\t\t<\/div><\/div><p>Below is a Perl script that demonstrates how to appropriately convert the current time from 24 hr format to 12 hr format. The  &#8216;convertToTwelveHr&#8217; subroutine does all the work here. The 24 hr input value is passed into the subroutine and a two-element list containing the 12 hr value equivalent and a string of either &#8216;AM&#8217; or &#8216;PM&#8217; is returned. <!--more--><br \/>\n<div id=\"attachment_3053\" style=\"width: 585px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/humairahmed.com\/blog\/wp-content\/uploads\/2011\/12\/perl_twelve_hr-e1323064475322.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3053\" src=\"http:\/\/humairahmed.com\/blog\/wp-content\/uploads\/2011\/12\/perl_twelve_hr-e1323064475322.png\" alt=\"Perl script that converts the time from 24 hr to 12 hr format\" title=\"Perl script that converts the time from 24 hr to 12 hr format\" width=\"575\" height=\"517\" class=\"size-full wp-image-3053\" \/><\/a><p id=\"caption-attachment-3053\" class=\"wp-caption-text\">Perl script that converts the time from 24 hr to 12 hr format<\/p><\/div> <\/p>\n<p><strong><u>Output:<\/u><\/strong><br \/>\n<a href=\"http:\/\/humairahmed.com\/blog\/wp-content\/uploads\/2011\/12\/perl_twelve_hr_out.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/humairahmed.com\/blog\/wp-content\/uploads\/2011\/12\/perl_twelve_hr_out.png\" alt=\"Perl script output - 24 hr to 12 hr time conversion\" title=\"Perl script output - 24 hr to 12 hr time conversion\" width=\"73\" height=\"20\" class=\"alignleft size-full wp-image-3056\" \/><\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below is a Perl script that demonstrates how to appropriately convert the current time from 24 hr format to 12 hr format. The &#8216;convertToTwelveHr&#8217; subroutine does all the work here. The 24 hr input value is passed into the subroutine &hellip; <a href=\"https:\/\/humairahmed.com\/blog\/?p=3042\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[382,5,3],"tags":[803,802,800,539,799,798,386,804,797,801],"class_list":["post-3042","post","type-post","status-publish","format-standard","hentry","category-perl","category-programming","category-technology","tag-24-hour-to-12-hour","tag-24-hr-to-12-hr","tag-converting-the-time-from-24-hr-to-12-hr-format","tag-localtime","tag-localtime-function","tag-localtime-subroutine","tag-perl-2","tag-perl-24-hour-to-12-hour","tag-perl-script","tag-perl-script-that-converts-time-from-24-hr-to-12-hr"],"_links":{"self":[{"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3042"}],"version-history":[{"count":31,"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3042\/revisions"}],"predecessor-version":[{"id":3460,"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3042\/revisions\/3460"}],"wp:attachment":[{"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/humairahmed.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}