This works on my PowerShell 5 on my computer; I can't get it working on TIO:
PowerShell 5, 97 bytes
function s($m,$d){1+(New-Timespan -st (Get-Date -day 1 -mo 1) -e (Get-Date -day $d -mo $m)).Days}
Call as s 2 11
for the example date (month before day-of-month).
Golfed by @mazzy, 82 bytes
PowerShell, 82 bytes
param($m,$d)1+(New-Timespan -st (Date -day 1 -mo 1) -e (Date -day $d -mo $m)).Days
The golfing relies on an alias or implementation of command (Date
) that does not exist in a default Windows 10 installation of PowerShell 5. The TIO PowerShell is PowerShell 6 on Linux.