yellow Posted October 17, 2005 Share Posted October 17, 2005 Hi all! I am quite new here. I met a time question: step 1: set a time in hh:mm:ss format step 2: add some minutes step 3: separate the new time into hour , minute, second (3 variables) Anyone know how? thanx! Link to comment Share on other sites More sharing options...
svennie Posted October 17, 2005 Share Posted October 17, 2005 (edited) Hi all! I am quite new here. I met a time question:step 1: set a time in hh:mm:ss formatstep 2: add some minutes step 3: separate the new time into hour , minute, second (3 variables)Anyone know how? thanx!Step 1:Use this script:$FormattiedTime=@HOUR&":"&@MIN&":"&@SECStep 2 and 3:Use this script:$NewTime=@MIN+5Problem will be when the time is 58 and then you add 5 to it you will get 63, thats not a minute time, to fix that use this code:$NewTime=@MIN+5 If $NewTime>59 Then ;if its more then 59 $hour=@HOUR+1 $minutes=$NewTime-($NewTime-59) $seconds=@SEC Else ;if time is lower then 59 $hour=@HOUR $minutes=$NewTime $seconds=@SEC EndIfChange the 5 in @MIN+5 to the minutes you want to add. Edited October 17, 2005 by svennie Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF Link to comment Share on other sites More sharing options...
yellow Posted October 18, 2005 Author Share Posted October 18, 2005 Thank you svennie! But I think there may be one more problem, if I add 63 minutes , the hour will not be right. _DateAdd( 'n',15, _Nowcalc()) will be ok but I don't how to seperate the new data ( like 2005/11/23 10:09:23) to 3 variables , hour , minute and second. Link to comment Share on other sites More sharing options...
CyberSlug Posted October 18, 2005 Share Posted October 18, 2005 Remove date from result by TRIMming from the position of the space between time and date. StringSplit the new result into an array. Assign the array elements to separate variables #include <Date.au3> $result = _DateAdd( 'n',15, _Nowcalc()) $result = StringTrimLeft($result, StringInStr($result," ")) $result = StringSplit($result,":") If @error Then Exit;if stringSplit failed.... $hour = $result[1] $minute = $result[2] $second = $result[3] MsgBox(4096,"Here",$hour & " : " & $minute & " : " & $second) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
yellow Posted October 18, 2005 Author Share Posted October 18, 2005 Thanks CyberSlug! It is very usefull, thanks a lot! 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