Advertisement
Guest User

Gravity Forms Calculate Time PHP 5.2

a guest
Feb 21st, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. add_action("gform_pre_submission_2","pre_submission_handler");
  2. function pre_submission_handler($form) {
  3.     $format = '%r';
  4.     $start = $_POST["input_1"];
  5.     $end = $_POST["input_2"];
  6.    
  7.     $startA = strtoupper($start[2]);
  8.     $endP = strtoupper($end[2]);
  9.    
  10.     $startdate = $start[0].':'.$start[1].' '.$startA;
  11.     $enddate = $end[0].':'.$end[1].' '.$endP;
  12.    
  13.     $starttime = strptime($startdate, $format);
  14.     $endtime = strptime($enddate, $format);
  15.    
  16.     $hours = (($endtime['tm_min'] + ($endtime['tm_hour'] * 60)) / 60) - (($starttime['tm_min'] + ($starttime['tm_hour'] * 60)) / 60);
  17.     $_POST["input_3"] = $hours;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement