Below is a Perl script that demonstrates how to appropriately convert the current time from 24 hr format to 12 hr format. The ‘convertToTwelveHr’ 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 ‘AM’ or ‘PM’ is returned.
Blog Archives
Search Blog Archives