Perfect. Thank-you very much :)
Mark Carruth
----- Original Message -----
From: "Nasser Saleem Ahmed" <nas@s...>
To: "professional php" <pro_php@p...>
Sent: Monday, April 22, 2002 2:55 PM
Subject: [pro_php] RE: Time Remaining
> Easy, write a simple function that does this (Pseudcode included)...
>
> TimeSpan = Second number - first number (obviuosly second date should be
> greater than first)
>
> SecondsInDay = 60 (seconds in minute) x 60 (minutes in hour) x 24
> 86400 (seconds in day) SecondsInHour = 60 (seconds in minute) x 60
> (minutes in hour) = 3600 (seconds in hour)
>
> Function CalculateDays
> If TimeSpan > SecondsInDay then
> Days = TimeSpan/SecondsInDay (days left)
> Return Days
> EndIf
> End Function
>
> Function CalculateHours
> If TimeSpan > SecondsInHour & TimeSpan < SecondsInDay then (there are
> only hours left)
> Hours = TimeSpan/SecondsInHour (hours left)
> Return Hours
> EndIf
> End Function
>
> Function CalculateMinutes
> If TimeSpan < SecondsInHour then (there are only minutes left)
> Minutes = TimeSpan/60 (minutes left)
> Seconds = Remainder are then seconds left
> Return Minutes Seconds (array)
> EndIf
> End Function
>
> Needs some work and could also write a class to do these calcualtions,
> you may want to search on the wbe as someone may have already wrote
> this, try the http://www.zend.com/codex.php code galleries...
>
> Found this http://www.zend.com/codex.php?id=725&single=1, which is the
> complete solution, so much for my code!!!
>
> Nasser :)
>
> -----Original Message-----
> From: Mark Carruth [mailto:mcarruth@t...]
> Sent: 21 April 2002 18:16
> To: professional php
> Subject: [pro_php] Time Remaining
>
>
> Here's an interesting problem I encountered when writing a script. I
> have two dates, which I can easily turn into Unix Timestamps, what is
> the easiest to work out how much time there is between the two? i.e. 2
> days, 5 hours etc.
>
> Any Help appreciated.
>
> TIA,
>
> Mark Carruth
>
>
>
>
>
>