Taken from here.
Partial Year Contributions If you establish an HSA by at least December of any year, your maximum contribution is the maximum amount (described above) for that calendar year. However, if you choose to discontinue the qualified plan any time in the next 12 month period, the maximum contribution will be prorated for the number of full months in which the qualified plan was in force. You will be charged tax on the funds that exceed the maximum, as well as a ten percent tax penalty.
Contribution Deadlines HSA contributions must be made for a specific year on or before the due date (without extensions) for filing tax returns for that year. So contributions must be made on or before April 15th or the date you file your taxes, whichever comes first.
If I open an HSA after Dec. 31, 2018, any contribution (in 2019) goes toward the 2019 contribution limit? But the contributions made during Jan. - April 15, 2019 can be deducted from my 2018 gross income?