gr1fter Posted August 16, 2010 Share Posted August 16, 2010 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 Link to comment Share on other sites More sharing options...
bogQ Posted August 16, 2010 Share Posted August 16, 2010 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 connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
gr1fter Posted August 16, 2010 Author Share Posted August 16, 2010 (edited) 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 August 16, 2010 by gr1fter Link to comment Share on other sites More sharing options...
bogQ Posted August 16, 2010 Share Posted August 16, 2010 You still have seconds there try StringMid TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
gr1fter Posted August 16, 2010 Author Share Posted August 16, 2010 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 More sharing options...
bogQ Posted August 16, 2010 Share Posted August 16, 2010 My bad, sry, your using Default: 3 so on my comp settings are different TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
somdcomputerguy Posted August 16, 2010 Share Posted August 16, 2010 (edited) 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 August 17, 2010 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now