WASHINGTON — Parents who need to change their kids’ diapers could soon have an easier time of it in federal buildings.

Congress sent legislation to President Obama on Thursday that would require baby changing stations in both men’s and women’s restrooms in federal buildings that are open to the public. Those buildings include courthouses, post offices, Social Security offices and some government-run museums like the Holocaust Memorial Museum and the National Archives.

The legislation was passed by voice vote in the Senate after winning House approval last week on a 389-34 vote.

Under the bill, the buildings would be required to have at least one baby-changing facility on each floor. The legislation would require the changes within two years, and makes some exceptions for situations in which the construction would be cost-prohibitive.

“Government needs to do more to ensure that public buildings are family-friendly,” said Rep. David Cicilline, D-R.I., who sponsored the bill. “No mom or dad should ever have to worry about finding a safe, sanitary place to change their baby — least of all in a federal building that’s paid for by taxpayers.”

He said the lack of adequate facilities can force families to change babies on countertops or the floor, which puts the health of the baby and also other restroom patrons at risk.