Jump to content
Sign in to follow this  
gr1fter

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

Recommended Posts

gr1fter

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

in the help there is only 12 hour format with seconds or 24 hour with no seconds. How can i get 12 hour format without seconds? Thanks

Share this post


Link to post
Share on other sites
bogQ

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.

 

Share this post


Link to post
Share on other sites
gr1fter

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

Share this post


Link to post
Share on other sites
bogQ

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.

 

Share this post


Link to post
Share on other sites
gr1fter

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

Share this post


Link to post
Share on other sites
bogQ

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.

 

Share this post


Link to post
Share on other sites
somdcomputerguy

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.

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  

×