The state Senate today passed a measure to give towns two more years to spend affordable housing funds they’ve accumulated, sending it on to the governor’s desk. Under a four-year-old law, towns across the state are set to forfeit about $161 million next month that they had collected from developers that was intended to help them build affordable housing. But mayors complained that the state’s affordable housing formula has been tied up in court, giving them no guidance as to how to spend the money. What’s more, they said, taking away the money would not rid them of affordable housing obligations, forcing taxpayers to pick up the costs. The Senate passed the measure 27-12. The Assembly voted 51-19 with nine abstentions to pass it on Monday.