flemingmike Posted October 20, 2010 Share Posted October 20, 2010 hello, is there a way to have php code determine what payroll week it is, or is it best to have a start date and end date in a table? Link to comment https://forums.phpfreaks.com/topic/216315-biweekly-payroll/ Share on other sites More sharing options...
flemingmike Posted October 20, 2010 Author Share Posted October 20, 2010 so, i have these set: $payrollstart="2010-10-16"; $payrollend="2010-10-29"; i cant wrap my head around how to start this thing off. Link to comment https://forums.phpfreaks.com/topic/216315-biweekly-payroll/#findComment-1124182 Share on other sites More sharing options...
flemingmike Posted October 20, 2010 Author Share Posted October 20, 2010 ultimately when i get this page finished, there will be a drop down box full of dates of payroll ending days. from that, it will show all timesheetes between payroll start and finish dates for that period. Link to comment https://forums.phpfreaks.com/topic/216315-biweekly-payroll/#findComment-1124184 Share on other sites More sharing options...
BlueSkyIS Posted October 20, 2010 Share Posted October 20, 2010 how do you define what payroll week it is? are you counting 52+/- weeks, or is it bi-weekly every 14 days, or on the 1st and 15th of each month, etc.? Link to comment https://forums.phpfreaks.com/topic/216315-biweekly-payroll/#findComment-1124185 Share on other sites More sharing options...
flemingmike Posted October 20, 2010 Author Share Posted October 20, 2010 here is what i was talking about: <?php $payrollstart="2010-10-16"; $payrollend="2010-10-29"; $payrollnum="0"; echo date('Y-m-d', strtotime($payrollstart) ), "<br />"; echo date('Y-m-d', strtotime($payrollend) ), "<br />"; echo $payrollnum; echo "<br /><br /><br />"; function round_nearest($no,$near) { return ceil($no/$near)*$near; } $date=date('Y-m-d'); $startdatestring = strtotime($payrollend); $nowstring = strtotime($date); $diffsecs=($nowstring - $startdatestring); $days = round($diffsecs / 86400); echo $days; echo "<br />"; $days1 = round_nearest($days, 14); echo $days1; echo "<br />"; $weeks=($days1 / 7); echo $weeks; echo "<br /><br /><br />"; $payrollweek=$weeks; echo date('Y-m-d', strtotime("+$payrollweek week $payrollstart") ), "<br />"; echo date('Y-m-d', strtotime("+$payrollweek week $payrollend") ), "<br />"; echo $payrollweek; ?> now i just need to figure out how to make a drop down list that shows date('Y-m-d', strtotime("+$payrollweek week $payrollend") ) as the first date and an array of the last 5 pay periods(the friday date) Link to comment https://forums.phpfreaks.com/topic/216315-biweekly-payroll/#findComment-1124206 Share on other sites More sharing options...
flemingmike Posted October 20, 2010 Author Share Posted October 20, 2010 here is what i came up with: <?php $payrollstart="2010-10-02"; $payrollend="2010-10-15"; $payrollnum="0"; echo date('Y-m-d', strtotime($payrollstart) ), "<br />"; echo date('Y-m-d', strtotime($payrollend) ), "<br />"; echo $payrollnum; echo "<br /><br /><br />"; function round_nearest($no,$near) { return ceil($no/$near)*$near; } $date=date('Y-m-d'); $startdatestring = strtotime($payrollend); $nowstring = strtotime($date); $diffsecs=($nowstring - $startdatestring); $days = round($diffsecs / 86400); echo $days; echo "<br />"; $days1 = round_nearest($days, 14); echo $days1; echo "<br />"; $weeks=($days1 / 7); echo $weeks; echo "<br /><br /><br />"; $payrollweek=$weeks; $payrollweekstart = date('Y-m-d', strtotime("+$payrollweek week $payrollstart") ); $payrollweekstart1 = date('l F j, Y', strtotime("$payrollweekstart") ); $payrollweekend = date('Y-m-d', strtotime("+$payrollweek week $payrollend") ); $payrollweekend2 = date('l F j, Y', strtotime("$payrollweekend") ); echo $payrollweek, "<br />"; echo $payrollweekstart1, "<br />"; echo $payrollweekend2, "<br />"; echo "<br /><br /><br />"; $payrollweek2=($payrollweek - 2); $payrollweek3=($payrollweek - 4); $payrollweek4=($payrollweek - 6); $payrollweek5=($payrollweek - ; $payperiod = date('Y-m-d', strtotime("+$payrollweek week $payrollend") ); $payperiod2 = date('Y-m-d', strtotime("+$payrollweek2 week $payrollend") ); $payperiod3 = date('Y-m-d', strtotime("+$payrollweek3 week $payrollend") ); $payperiod4 = date('Y-m-d', strtotime("+$payrollweek4 week $payrollend") ); $payperiod5 = date('Y-m-d', strtotime("+$payrollweek5 week $payrollend") ); ?> <form method="POST"> Pay Period Ending: <select size="1" name="payperiod"> <option selected value="<?php echo $payperiod; ?>"><?php echo date('F j, Y', strtotime("$payperiod") ); ?></option> <option value="<?php echo $payperiod2; ?>"><?php echo date('F j, Y', strtotime("$payperiod2") ); ?></option> <option value="<?php echo $payperiod3; ?>"><?php echo date('F j, Y', strtotime("$payperiod3") ); ?></option> <option value="<?php echo $payperiod4; ?>"><?php echo date('F j, Y', strtotime("$payperiod4") ); ?></option> <option value="<?php echo $payperiod5; ?>"><?php echo date('F j, Y', strtotime("$payperiod5") ); ?></option> </select> <input type="submit" value="View" name="view"> </form> Link to comment https://forums.phpfreaks.com/topic/216315-biweekly-payroll/#findComment-1124217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.