Taxes are probably the last thing on anyone's mind in the flooded parts of Texas.

But the IRS said Monday it will grant an automatic extension to individuals and businesses who are victims of Hurricane Harvey. They'll have until Jan. 31, 2018 to file and pay federal taxes that were due between Aug. 23 and January 2018.

"This has been a devastating storm, and the IRS will move quickly to provide tax relief to hurricane victims," said IRS Commissioner John Koskinen. "The IRS will continue to closely monitor the storm's aftermath, and we anticipate providing additional relief for other affected areas in the near future."

Related: Anheuser-Busch will provide water to victims of Hurrican Harvey

Currently the extension applies to the 18 counties in Texas that the Federal Emergency Management Agency has determined need assistance: Aransas, Bee, Brazoria, Calhoun, Chambers, Fort Bend, Galveston, Goliad, Harris, Jackson, Kleberg, Liberty, Matagorda, Nueces, Refugio, San Patricio, Victoria and Wharton.

The more lenient filing and payment deadline also may apply to anyone who lives outside the disaster area but who has to get records from that area to meet a tax deadline. It also includes people who are helping with relief efforts, as long as they are doing so in affiliation with a recognized government or philanthropic organization. The IRS says people can call 866-562-5227 to discuss their situation.

Related from CNN: How you can help those affected by Hurricane Harvey

Anyone who has been granted an extension to file their 2016 tax return by mid-October can now take until the Jan. 31 deadline to file their paperwork. But, if they owe money for 2016, they'll still have to pay a late payment penalty and interest. That's because 2016 payments were due in full on April 18, months before the storm.

Among others that will benefit from the IRS extension are businesses that file estimated taxes in September and January, as well as employers that file quarterly payroll and excise tax returns.