What you are looking for is
man strftime
This means that the format string-format-time is used, which is used in the date format.
So, to get the current AM / PM, use the following:
date +"%p"
or
ampm=`date +"%p"` echo $ampm
An hour can be one of several formats (do you want a 12 or 24 hour time, zero or not?) I assume you want a 12 hour time without a leading zero:
date +"%l"
valbaca
source share