php-general Digest 6 Oct 2013 22:19:43 -0000 Issue 8387

Topics (messages 322241 through 322242):

Re: Algorithm Help
        322241 by: Nickolas Whiting

date time problem
        322242 by: Jim Giner

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Round Robin algorithm should solve this and is a fairly quick alogrithm ...
http://en.wikipedia.org/wiki/Round-robin

An example can be found
http://forrst.com/posts/PHP_Round_Robin_Algorithm-2zm


On Tue, Oct 1, 2013 at 2:51 PM, Floyd Resler <fres...@adex-intl.com> wrote:

> Here's my task: A group of kids is going to be staying with different host
> families throughout the next 8 months.  The number of kids staying with a
> host family can range from 2 to 10.  When deciding which kids should stay
> together at a host family, the idea is for the system to put together kids
> who have stayed with each other the least on past weekends.  So, if a host
> family can keep 5 kids, then the group of 5 kids who have stayed together
> the least will be chosen.
>
> I can't think of an easy, quick way to accomplish this.  I've tried
> various approaches that have resulted in a lot of coding and being very
> slow.  My idea was to give each group of kids a score and the lowest score
> is the group that is selected.  However, this approach wound of iterating
> through several arrays several times which was really slow.  Does anyone
> have any ideas on this puzzle?
>
> Thanks!
> Floyd
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Nickolas Whiting
Freelance Consultant

--- End Message ---
--- Begin Message --- I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by....

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get this right?
--- End Message ---

Reply via email to