Jump to content

Easy way to get time in 12 hour format with no seconds?


Recommended Posts

You did not tell or post func with what you have problem

So heare is one example based on 'Macro Reference - Time And Date'

$var = @HOUR
If $var > 12 then $var -= 12
If StringLen($var) = 1 Then $var = '0'&$var
$time = $var&":"&@MIN
MsgBox(0,"",$time)

Edit it to do what you need

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I apologize,

I actually went digging around in the help files and found something that is working for me, I'm not sure if it is the best way, but seems right. I appreciate your response

$s12time = _NowTime(3);12 Hour Time

$ampm = StringRight ($s12time,2)
$time = StringTrimRight($s12time,6)
$shorttime = $time & " " & $ampm

MsgBox  (0,"",$time & " " & $ampm)
Edited by gr1fter
Link to comment
Share on other sites

You still have seconds there ;)

try StringMid

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

it shows correct on my computer: ;)

$s12time = _NowTime(3);12 Hour Time = the current time on the computer 12 hour with seconds

$ampm = StringRight ($s12time,2) = I extract the AM or PM and save it for later

$time = StringTrimRight($s12time,6) = I trim the right 6 strings which would be :00 PM

$shorttime = $time & " " & $ampm = I add the shortened time without seconds and the AM/PM back

Link to comment
Share on other sites

My bad, sry,

your using Default: 3 so on my comp settings are different

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I don't know if you've figured out a way to go or whatever, but I'll just post this function I wrote to use in a clock type script. Maybe it'll be of some help or something for you. There isn't an 'am/pm' thing, but that can be added pretty easily, in the Switch..

Func TheTime()
    Local $vLittleHand, $aHourSplit = StringSplit(@HOUR, "", 2)
    If $TimeDisplay = 12 Then
        Switch @HOUR
            Case 0
                $vLittleHand = 12
            Case 1 To 9
                $vLittleHand = " " & $aHourSplit[1]
            Case 10 To 12
                $vLittleHand = @HOUR
            Case 13 To 21
                $vLittleHand = " " & @HOUR - 12
            Case 22 To 23
                $vLittleHand = @HOUR - 12
        EndSwitch
        Return($vLittleHand & ":" & @MIN)
    Else
        Return(@HOUR & @MIN)
    EndIf
EndFunc ;==> TheTime()
Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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