W
W
walder2020-06-09 13:31:26
PHP
walder, 2020-06-09 13:31:26

How to calculate the time from the date of completion of the production of goods?

Hello.

Faced such a task, to calculate the time, but only back, from the date when the goods should be ready. For example, there is a product that consists of two or three parts, to make each of them, you need to take several steps. If shown in the table, it looks like this:

Product
-Detail 1
- step 1 - 5 hours
- step 2 - 2 hours -
step 3 - 1 hour
-Detail 2
- step 1 - 5 hours -
step 2 - 4 hours -
step 3 - 3 hours

I know how much time I will spend on a certain step, if I calculated consistently, then everything is very clear and understandable, there is a start date and time, there is a duration of steps ...
Each step is a separate machine on which the step is executed, and the steps are executed one after the other ... but also the parts are independent of each other, they can also be executed at the same time. That is, if part 1 - w1 is completed, I can start d2 - w1 and, respectively, d1 - w2 and d2 - w2, but do not forget that until d2 - w1 is completed, then I can’t start d2 - w2 either, and so on ...

if I start at 12:00
-Detail 1
--step 1 - 5 hours, end at 17:00
--step 2 - 2 hours, finish at 19:00
--step 3 - 1 hour, finish at 20:00
-Detail 2
- --step 1 - 5 o'clock, by law 22:00 (because d1 - sh1 will be ready at 17:00 and there are no steps before it)
--step 2 - 4 hours, finish at 11:00 pm (I can only start at 10:00 pm, since step 1 for this part will be completed at that time, but if step 1 takes less time than step 1 for part 1, then accordingly I can start it ...)
...

I don’t know if I explained it clearly ...

the whole difficulty is that I have to calculate from the date when the goods must be fully assembled.
if i have to finish at 00:00 o'clock, i have to calculate when i need to start the production of goods at least to finish before that time, and the calculation should be reversed...

if i have to finish at 00:00
-detail 1
--step 1 - 5 o'clock. when should i start???? (you need to take into account when all the details and steps are completed, respectively, this step should be started before everyone else)
--step 2 - 2 hours,
--step 3 - 1 hour,
-Detail 2
--step 1 - 5 hours
--step 2 - 4 hours
--step 3 - 1 hour

I apologize in advance for the clumsy presentation, I hope at least something is clear))) maybe there people who faced such task?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OxCom, 2020-06-09
@walder

If you can calculate time forward, then what prevents you from calculating backward? At least do this:
- calculate everything ahead and get the end date $dEndNow, if we start now $dStartNow
- find the delta $delta of the time between $dEndNow and the time to finish the job $dEndReq
- add the delta $delta to the current time $dStartNow and get the start time. Yes, the delta can be negative, but this is the case when we have already missed the start moment in order to finish on time.
Using this delta, you can also specify the start time for each task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question