I hope this doesn't get duplicated - I wrote this up and submitted it, but it never showed up on the page.
I'm new to PHP and have been to tens of pages online that supposedly explain how to create a datediff function to show the difference between 2 dates, but none of them seem to do what I need.
I have an HTML form that includes a $start_date and $end_date (in yyyy-mm-dd format). When submitted, the following PHP page should calculate the difference between those 2 dates in working days (no weekends) and create the new value called $duration. Below is a snippet of the code from the submitting PHP page that should give an idea of what I'm trying to do (although this obviously doesn't work):
//$_GET['all the variables from the HTML form'];
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
$duration = datediff($_POST['end_date'], $_POST['start_date']); //but this needs to only include weekdays (non-public holiday weekdays if possible)
// update data in mysql database
$sql="UPDATE table_name SET start_date='$start_date', end_date='$end_date', duration='$duration''";
$result=mysql_query($sql);
I've seen snippets of code online that relates to this, but none show a whole function and value placement from start to finish and I haven't been able to piece it together.
Any help here would be very much appreciated.