Forums / General Questions / Subtracting 15 minutes from Time, to display a pickup time

Subtracting 15 minutes from Time, to display a pickup time

Views: 881

Results 1 to 4 of 4
25 Sep 2012, 5:56 PM
#1
fooddudes avatar

fooddudes

New Zenner

Join Date:
Nov 2008
Posts:
33
Plugin Contributions:
0

Subtracting 15 minutes from Time, to display a pickup time

I am trying to display the pickup date and time on invoices. I need the pickup time to be 15 minutes less the order_delivery_date_time. Any help is appreciated. Thanks

if ($order->info['order_delivery_date_time'] > '00:00:01') {
$pos = $pdf->ezText("<b>" . PDFOC_TEXT_ORDER_DATE . " </b>" . zen_date_short($order->info['order_delivery_date_day']) . " " . convert24to12($order->info['order_delivery_date_time']));
} else {
$pos = $pdf->ezText("<b>" . PDFOC_TEXT_ORDER_DATE . " </b>" . zen_date_short($order->info['order_delivery_date_day']) . " " . "ASAP");
}

25 Sep 2012, 6:05 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: Subtracting 15 minutes from Time, to display a pickup time

Googling php subtract minutes brings up a slew of pages ...

26 Sep 2012, 2:44 AM
#3
fooddudes avatar

fooddudes

New Zenner

Join Date:
Nov 2008
Posts:
33
Plugin Contributions:
0

Re: Subtracting 15 minutes from Time, to display a pickup time

lat9:

Googling php subtract minutes brings up a slew of pages ...

I tried to find a solution and have come up empty. I have no experience with MySQL Date and Time Functions. If someone could instruct me on how to subtract 15 minutes from $order->info['order_delivery_date_time'] i would appreciate it. Thanks

26 Sep 2012, 1:20 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: Subtracting 15 minutes from Time, to display a pickup time

Try the following. If you've got a variable that is in 24-hour time format (HH:MM:SS), then simply replace the $order_time variable in the explode (and delete the first line) to get your 15-minutes off:

$order_time = '08:54:00';
$time = explode(':', $order_time);
$newTime = mktime($time[0], $time[1], $time[2]) - 15 * 60; // $order_time - 15 minutes
$pickupTime = strftime('%H:%M:%S', $newTime);  // $pickupTime = '08:39:00'