Just did this myself. Got it a bit shorter though =)
$lastWorkingDay = date( "d", strtotime("today -1 Weekday") );
Or if you need to include today too, like in my case:
$lastWorkingDay =(date("N")<=5)?date("Y-m-d"):date("Y-m-d",strtotime('today -1 Weekday'));
Just did this myself. Got it a bit shorter though =)
$lastWorkingDay = date( "d", strtotime("today -1 Weekday") );
Or if you need to include today too, like in my case:
$lastWorkingDay =(date("N")<=5)?date("Y-m-d"):date("Y-m-d",strtotime('today -1 Weekday'));