Sign in to follow this  
Followers 0
cypher175

Force 12-hour Time format..?

4 posts in this topic

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..??

Share this post


Link to post
Share on other sites



anybody know if this is possible at all..??

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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... :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0