# time problem

## Recommended Posts

Hi all! I am quite new here. I met a time question:

step 1: set a time in hh:mm:ss format

step 3: separate the new time into hour , minute, second (3 variables)

Anyone know how? thanx!

##### Share on other sites

Hi all! I am quite new here. I met a time question:

step 1: set a time in hh:mm:ss format

step 3: separate the new time into hour , minute, second (3 variables)

Anyone know how? thanx!

Step 1:

Use this script:

`\$FormattiedTime=@HOUR&":"&@MIN&":"&@SEC`

Step 2 and 3:

Use this script:

`\$NewTime=@MIN+5`

Problem 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
EndIf```

Change the 5 in @MIN+5 to the minutes you want to add.

Edited by svennie

Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

##### Share on other sites

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.

##### Share on other sites

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 = 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!

##### Share on other sites

Thanks CyberSlug! It is very usefull, thanks a lot!

## Create an account

Register a new account