TomCat Posted October 1, 2007 Share Posted October 1, 2007 Hi some Question i have two Times. One Variable with curent time and an other with past time value. $timepast = 00:59 $timecurent = 01:06 How can i make a funktion which start something if the difference between $timepast and $timecurent is more than 5 Minutes ? Hope you can help me Link to comment Share on other sites More sharing options...
flip209 Posted October 1, 2007 Share Posted October 1, 2007 TimerDiff ( timestamp ) " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln Link to comment Share on other sites More sharing options...
longtex Posted October 1, 2007 Share Posted October 1, 2007 Hi some Question i have two Times. One Variable with curent time and an other with past time value. $timepast = 00:59 $timecurent = 01:06 How can i make a funktion which start something if the difference between $timepast and $timecurent is more than 5 Minutes ? Hope you can help me Here's a little code I wrote for times > 24 hours (although it should work regardless) #include <Date.au3> ; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00) ;$iDateCalc = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc()) ;MsgBox( 4096, "", "Number of seconds since EPOCH: " & $iDateCalc ) ; ; How long have I been waiting for the PROMISED "within 24 hours" response ; from Symantec Tech "Support"? Since 1:35PM on 8/7/2007... ; Every so often I get a message from Symantec, and I edit ; the part that starts "... I've been waiting for your response ; for xxxx hours now; how long do you think I'll have to wait?" $origdt = @YEAR & "/08/07 13:35:00" ; Calculated the number of Hours this year $iDateCalc = _DateDiff( 'h',$origdt,_NowCalc()) MsgBox( 4096, "", $idatecalc & " hours since "&$origdt ) Nobody needs a job. Not much, anyway. Before you need a job, there's a lot of other stuff you need. More or less in order of how badly you need them: AIR, WATER, FOOD, SHELTER, CLOTHING, COMPANIONSHIP, and ACTIVITY. You've been led to believe you need money to "pay" someone else to provide those for you - all but AIR, so far. How long is it going to be before you have to "pay" for AIR, too? Link to comment Share on other sites More sharing options...
Nahuel Posted October 2, 2007 Share Posted October 2, 2007 (edited) I made this once, I had to fix it now:expandcollapse popupFunc _TimeDiff($iStartTime,$iEndTime) Local $iTimeDiff[2] ;*EndTime must be higher than StartTime. ;*It returns difference in minutes ($Diff[0]) and in seconds ($Diff[1]) ;*Times must be in the format "XX:XX:XX" ;Split the time $iStartTimeSplit=StringSplit($iStartTime,":") $iEndTimeSplit=StringSplit($iEndTime,":") ;Check parameters If UBound($iStartTimeSplit)=3 Then SetError(2);Time is not in correct form Return EndIf If UBound($iEndTimeSplit)=3 Then SetError(2);Time is not in correct form Return EndIf ;Check if StartTime is lower than EndTime If $iStartTimeSplit[1] > $iEndTimeSplit[1] Then SetError(1) Return 1;StartTime>Endtime EndIf ;Check if the times are valid If $iStartTimeSplit[1] > 23 or $iStartTimeSplit[2] > 60 or $iStartTimeSplit[3] > 60 or _ $iEndTimeSplit[1] > 23 or $iEndTimeSplit[2] > 60 or $iEndTimeSplit[3] > 60 Then SetError(1) Return -1 EndIf If $iStartTimeSplit[1]=$iStartTimeSplit[2] AND $iEndTimeSplit[1]=$iEndTimeSplit[2] Then SetError(1) Return 1;StartTime>Endtime EndIf ;Do the maths :P $iHoursDiff=$iEndTimeSplit[1]-$iStartTimeSplit[1] $iHoursDiffinMins=$iHoursDiff*60 $iMinsDiff=$iEndTimeSplit[2]-$iStartTimeSplit[2] If $iStartTimeSplit[3] > $iEndTimeSplit[3] Then $iSecsDiff=60-$iStartTimeSplit[3] Else $iSecsDiff=$iEndTimeSplit[3]-$iStartTimeSplit[3] EndIf $iMinsTotal=$iMinsDiff+$iHoursDiffinMins $iTimeDiff[0]=$iMinsTotal $iTimeDiff[1]=$iSecsDiff Return $iTimeDiff EndFuncI think it works fine... check it first.Examples:$timepast = "00:59:00" $timecurent = "01:06:00" $Diff=_TimeDiff($timepast,$timecurent) If not @error Then MsgBox(0,"","The difference is "&$Diff[0]&" mins and "&$Diff[1]&" secs.")$timepast = "00:00:20" $timecurent = "00:00:00" $Diff=_TimeDiff($timepast,$timecurent) If not @error Then MsgBox(0,"","The difference is "&$Diff[0]&" mins and "&$Diff[1]&" secs.")Let me know if there's some bug, I'm interested in this as well Edited October 2, 2007 by Nahuel Link to comment Share on other sites More sharing options...
TomCat Posted October 2, 2007 Author Share Posted October 2, 2007 Tnx guys i got it work using modification of longtex's script Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 2, 2007 Share Posted October 2, 2007 Hi some Question i have two Times. One Variable with curent time and an other with past time value.$timepast = 00:59$timecurent = 01:06How can i make a funktion which start something if the difference between $timepast and $timecurent is more than 5 Minutes ?Hope you can help me What do those times represent? How are they formatted? Min:Sec, Hr:Min, ...? Is it elapsed time, or clock time (will one of the numbers roll over from 12 to 01, 23 to 00, or 59 to 00)? Will either number ever be less than or more than two digits?The function you want to perform will be easy, but must take into account that kind of formatting info to get an accurate result in all cases. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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