FORUMS


Hello There, Guest! Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculating time Difference with Submission Pre-Parser
#1
Exclamation 
So i been trying to get this going calculating time difference of my for form.

Below is my code.

if (isset($_POST["checkin"]) && $_POST["checkout"]) {
$tcheckin = $_post['checkin']; $tcheckout = $_post['checkout'];
 $tdiff = date_diff("$tcheckin","$tcheckout")->format("%H:%I:%S");
$_POST["inandout"]=["$tdiff"];
exit;

I am not sure what i am doing wrong.
Reply
#2
Exclamation 
(Aug 25th, 2017, 11:10 AM)ramonbps Wrote: So i been trying to get this going calculating time difference of my for form.

Below is my code.

if (isset($_POST["checkin"]) && $_POST["checkout"]) {
$tcheckin = $_post['checkin']; $tcheckout = $_post['checkout'];
 $tdiff = date_diff("$tcheckin","$tcheckout")->format("%H:%I:%S");
$_POST["inandout"]=["$tdiff"];
exit;

I am not sure what i am doing wrong.

 this is my actually code[Image: 6rLM05J]

PHP Code:
$tcheckin=$_POST["checkin"];
$tcheckout=$_POST["checkout"];
$tdiff date_diff($tcheckin,$tcheckout)->format("%H:%I:%S");
$_POST["inandout"]=["$tdiff"];

When i remove ->format("%H:%i:%s"the blank page goes away
[Image: Kv8OT]
[Image: Kv8OT][Image: 6rLM05J]Attach is the blank page i get.


Attached Files Thumbnail(s)
   
Reply
#3
Im trying something like that... but I fail like the new Death Note movie :S
Leeroy Jenkins...
Reply
#4
What have you tried maybe we can, come with a solution.
Reply
#5
So i got it working, this is what i did below. I hope this helps!.

PHP Code:
// Set Time Zone
date_default_timezone_set('America/Los_Angeles');
//Get Checkin
$tcheckin $_POST["checkin"];
//Get Checkout
$tcheckout $_POST["checkout"];
//Create Time Variable from checkin
$dteStart = new DateTime($tcheckin);
//Create Time Variable from checkout
$dteEnd   = new DateTime($tcheckout);
// Calculate Time Difference
$dteDiff  $dteStart->diff($dteEnd);
//Format Time
$ttdiff $dteDiff->format("%H:%I");
//Insert Time Differance to Total
$_POST["inandout"]=["$ttdiff"]; 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)