Forums: calculate the delivery date - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

calculate the delivery date sum two hours fild, calculate future,estimated arrival time Rate Topic: -----

#1 User is offline   ruzgarajans 

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 20-September 17

Posted 14 July 2018 - 08:26 PM

hi,
scenario;
I am ordering and delivery time depends on order.
how do I calculate the delivery date?

Does the delivery change over time when the product changes?

table:
  • Products tbl : "name (varchar) ", "order_preparation_time (TIME)"
  • order tbl : "products_name (varchar)", "orderpreparation_time (TIME)", "date_of_registration (TIME)function now()", "delivery_time (time)


note:(order_preparation_time, it is not timezone , it is only minute counter )
for example: this order takes 45 minutes: order_preparation_time = 00:45:00

date_of_registration: 13:00:00 (now())
products_name : product A
order_preparation_time: 00:45:00

delivery_time : 13:45:00


I did not write the code because they all failed.

Can you help me please

thank you very much
0

#2 User is offline   ruzgarajans 

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 20-September 17

Posted 15 July 2018 - 09:53 AM

i want to do,
I want to calculate the order delivery date instantly.

does this method work in date format?

https://xlinesoft.co..._on_the_fly.htm




















archive:

his example did not work on my application

http://asprunner.com...-in-fhe-future/

// Before record added
function BeforeAdd(&$values,&$message,$inline)
{
 
$kpi = $values["kpi"];
 
if ($kpi == "2.1")
$kpidate = date("Y-m-d H:i:s", time()+7200);
else if ($kpi == "2.2")
$kpidate = date("Y-m-d H:i:s", time()+10800);
else if ($kpi == "3.1")
$kpidate = date("Y-m-d H:i:s", time()+14400);
else if ($kpi == "4.1")
$kpidate = date("Y-m-d H:i:s", time()+96400);
else if ($kpi == "4.2")
$kpidate = date("Y-m-d H:i:s", time()+86400);
else if ($kpi == "4.3")
$kpidate = date("Y-m-d H:i:s", time()+345600);
else if ($kpi == "4.4")
$kpidate = date("Y-m-d H:i:s", time()+2592000);
else if ($kpi == "4.5")
$kpidate = date("Y-m-d H:i:s", time()+15552000);
 
$values["data_fim"] = $kpidate;
} // function BeforeAdd

// Before record updated
function BeforeEdit(&$values,$where,&$oldvalues,&$keys,&$message,$inline)
{
 
$kpi = $values["kpi"];
$opendate = $values["data_abertura"];
 
if ($kpi == "2.1")
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 120 minutes"));
else if ($kpi == "2.2")
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 180 minutes"));
else if ($kpi == "3.1")
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 240 minutes"));
else if ($kpi == "4.1")
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 1 days"));
else if ($kpi == "4.2")
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 1 days"));
else if ($kpi == "4.3")
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 4 days"));
else if ($kpi == "4.4")
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 30 days"));
else if ($kpi == "4.5")
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 180 days"));
 
$values["data_fim"] = $kpidate;
 
} // function BeforeEdit

0

#3 User is offline   ruzgarajans 

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 20-September 17

Posted 16 July 2018 - 08:51 PM

I need a clue to get started..
pls help me..
0

#4 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16046
  • Joined: 03-February 03

Posted 16 July 2018 - 09:36 PM

Your idea is correct but your syntax is wrong. Googling "PHP add days to date" we end up on this page
https://stackoverflo...-to-date-in-php that shows us correct syntax.

Instead of
$kpidate = date("Y-m-d H:i:s", strtotime("$opendate + 120 minutes"));

you should use
$kpidate = date("Y-m-d H:i:s", strtotime($opendate." + 120 minutes"));

Best regards,
Sergey Kornilov
0

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked