3v4l.org

run code in 300+ PHP versions simultaneously
<?php $punch_in = "2019-07-01 09:00:00"; $punch_out = "2019-07-01 18:00:00"; $in_threshold = "2019-07-01 08:15:00"; $out_threshold = "2019-07-01 17:15:00"; $exact_in_threshold = "2019-07-01 08:00:00"; $exact_out_threshold = "2019-07-01 17:00:00"; function generateAttendance( $punch_in, $punch_out , $in_threshold, $out_threshold , $exact_in_threshold, $exact_out_threshold){ $lates = 0; $overtime = 0; // If punch_in is late = punch_in and late + 1 if ($punch_in > $in_threshold) { $start = $punch_in; $lates = +1; } // If punch_in is early = exact_time else { $start = $exact_in_threshold; } // If punch_out is early = punch_out if ($punch_out < $out_threshold) { $end = $punch_out; } // If pucn_out is overtime = exact_end and overtime + 1 else { $end = $exact_out_threshold; $overtime =1; } // If both punch in and punch_out is within threshold if ((( $exact_in_threshold >= $in_threshold ) && ( $exact_in_threshold <= $punch_in )) && (( $exact_out_threshold >= $out_threshold ) && ( $exact_out_threshold <= $punch_out ))) { $start = $punch_in; $end = $punch_out; } // If punch_in is within threshold, start = punch_in and end = exact_end else if ((( $exact_in_threshold >= $in_threshold ) && ( $exact_in_threshold <= $punch_in )) && $punch_out > $out_threshold) { $start = $punch_in; $end = $exact_out_threshold; } return array('start' => $start, 'end' => $end, 'lates' => $lates, 'overtime' => $overtime); } $result = generateAttendance( $punch_in, $punch_out , $in_threshold, $out_threshold , $exact_in_threshold, $exact_out_threshold); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [start] => 2019-07-01 09:00:00 [end] => 2019-07-01 17:00:00 [lates] => 1 [overtime] => 1 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.43 ms | 401 KiB | 8 Q