Jump to content

Recommended Posts

Posted

Is there any way to Force a 12-hour Time format like: 5:32:11 PM, 12:32:11 AM

So whenever i need to get the time to use in a Variable or Function it will always return in the 12-hour AM-PM Time format..??

Can this be done in AutoIt at all..??

Posted

doing a search for "12 hour time", I found this:

http://www.autoitscript.com/forum/index.ph...hl=12+hour+time

Which is basically rolling your own logic. I tweaked it slightly.

msgbox(64,"Current time", "It is currently " & time12hr())

Func time12hr()
    $iHour = @HOUR 
    $iMin  = @MIN
    $iSec  = @SEC
    $sAMPM = "AM"
    If $iHour >= 12 Then $sAMPM = "PM"
    If $iHour = 00 Then $iHour = 12
    If $iHour > 12 Then $iHour -= 12
    Return $iHour & ":" & $iMin & ":" & $iSec & " "& $sAMPM
EndFunc
Posted

doing a search for "12 hour time", I found this:

http://www.autoitscript.com/forum/index.ph...hl=12+hour+time

Which is basically rolling your own logic. I tweaked it slightly.

msgbox(64,"Current time", "It is currently " & time12hr())

Func time12hr()
    $iHour = @HOUR 
    $iMin  = @MIN
    $iSec  = @SEC
    $sAMPM = "AM"
    If $iHour >= 12 Then $sAMPM = "PM"
    If $iHour = 00 Then $iHour = 12
    If $iHour > 12 Then $iHour -= 12
    Return $iHour & ":" & $iMin & ":" & $iSec & " "& $sAMPM
EndFunc
This should be a UDF...

If a minor change like the one between StringSplit() and _StringSplit() can make one a UDF, this should deffinately be a UDF... :)

SIGNATURE_0X800007D NOT FOUND

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
×
×
  • Create New...