Jump to content

12 Hour Clock


Recommended Posts

If you are talking about the @hour macro just subtract 12.

$hour = @HOUR
$string = "AM"
If $hour > 12 Then
    $hour -= 12
    $string = "PM"
EndIf
MsgBox(0,"", $hour & " " & $string)
It's almost, but not quite that simple. In your script, 00 hours in the morning would stay 00, not 12 AM. Also 12 noon would stay AM vice PM. Try:
Global $iHour = @HOUR, $sAMPM = "AM"
If $iHour >= 12 Then $sAMPM = "PM"
If $iHour = 00 Then $iHour = 12
If $iHour > 12 Then $iHour -= 12

MsgBox(64, "12H Time", "It's " & $iHour & ":" & @MIN & " " & $sAMPM)

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

;) How did I not think of that? Thank you much sir. I guess I was looking to hard to find a one liner instead of thinking to subtract 12. :D Isn't midnight displayed as 00? (the range says 00 to 23)No one should be on my program at midnight, but just to be accurate I'd have to add the extra if $hour = 0 then $hour += 12.

Edit: Psatlyds beat me to it

Edited by youknowwho4eva

Giggity

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...