Actually your solution is quite good, if you just want the time and don't want to use outside modules (i.e. Date::Calc which doesn't do you much good anyway for this problem). You do have a small bug though ... what if it is 12 NOON? With your code
if($hh > 12) { # hh = 12; $hh = $hh - 12; $ampm = "PM"; } else { $ampm = "AM"; # opps 12 PM just became 12 midnight. }
Test to see if the hour is 12 and set the $ampm to "PM" in that case without subtracting anything.
Hope that helps
Chris
In reply to Re: AM/PM in date and time format
by cfreak
in thread AM/PM in date and time format
by AcidHawk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |