I have the following code where I count the differences of days, but I want to deduct the weekends
<?php
$datetime1 = new DateTime($machine->fechasolicitud);
$datetime2 = new DateTime($machine->fecha);
$interval = $datetime1->diff($datetime2);
echo $interval->format('%R%a días');
?>
Is there any way in PHP or in MySql?
An approach in php with dates in date format is with a loop that goes through the period and asks for the day of the week:
To make it a little more automated, taking Carmen's answer as a reference, you can do it this way:
So you take the dates from the server and subtract them with the date of the current month, although some months may bring 31 days, other months do not, so you leave the automated process for any month of the year, you can subtract it with the current day and If what you want is to subtract the global month, you can eliminate the sdia variable so that it only takes day 1.
I hope it will serve you and the community that needs it, greetings.