By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,247 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,247 IT Pros & Developers. It's quick & easy.

Can somebody help me to write PHP function ? - Just in Time alghoritm.

P: n/a

Hi, I have verry big problem.
I must write function using dates.
This is a problem:
I have some dates for example: 2006-01-01, 2006-02-05, 2006-10-15 etc.

then some times: 20sec, 50sec, 45sec etc
and some quantity of parts: 200, 300, 240
---------------------------------------------------------------------
I must sort dates,times and quanties, then I must calculate:for ex.
2006-01-01+200*20, etc. and then add next date+quanntity*time. Please
HELP me.
It's like "Just In Time" alghoritm, I thing.

Thanks All for answer.
--
mario
------------------------------------------------------------------------
mario's Profile: http://techiegroups.com/member.php?userid=99
View this thread: http://www.techiegroups.com/showthread.php?t=109395

May 23 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
mario said the following on 23/05/2006 13:31:
Hi, I have verry big problem.
I must write function using dates.
This is a problem:
I have some dates for example: 2006-01-01, 2006-02-05, 2006-10-15 etc.

then some times: 20sec, 50sec, 45sec etc
and some quantity of parts: 200, 300, 240
---------------------------------------------------------------------
I must sort dates,times and quanties, then I must calculate:for ex.
2006-01-01+200*20, etc. and then add next date+quanntity*time. Please
HELP me.
It's like "Just In Time" alghoritm, I thing.


This is best achieved by converting the dates to timestamps (number of
seconds since 01/01/1970), using mktime(). Once you've done that, you
can add your ($quantity * $time) to the timestamp, and then reconvert
using date().

Quite what it is you want to sort, I'm not sure. But timestamps are
very easy to sort, as they're just integers.
--
Oli
May 23 '06 #2

P: n/a
I want to sort everything for example:
I must produce 200 parts. (it is 200*20 sec.) to 2006-01-01

I must sort all dates before, from min to max (max to min) and add all
results, then I must convert (reverse) into the dates.
p.s. sorry my English ist't good.
Mario

Uzytkownik "Oli Filth" <ca***@olifilth.co.uk> napisal w wiadomosci
news:Kd***************@newsfe1-win.ntli.net...
mario said the following on 23/05/2006 13:31:
Hi, I have verry big problem. I must write function using dates. This is
a problem: I have some dates for example: 2006-01-01, 2006-02-05,
2006-10-15 etc.

then some times: 20sec, 50sec, 45sec etc and some quantity of parts: 200,
300,
240 ---------------------------------------------------------------------
I must sort dates,times and quanties, then I must calculate:for ex.
2006-01-01+200*20, etc. and then add next date+quanntity*time. Please
HELP me. It's like "Just In Time" alghoritm, I thing.


This is best achieved by converting the dates to timestamps (number of
seconds since 01/01/1970), using mktime(). Once you've done that, you can
add your ($quantity * $time) to the timestamp, and then reconvert using
date().

Quite what it is you want to sort, I'm not sure. But timestamps are very
easy to sort, as they're just integers.
--
Oli

May 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.