Can I offset taxes for a 401k withdrawal with an IRA contribution?Do timetables apply?Do I have to make the IRA deposit by a certain time relative to the distribution?

I took a taxable distribution from my 401k in 2017. Can I offset the taxes from the distribution with an IRA contribution?  Do timetables apply.  For example, do I have to make the IRA contribution within a certain time of taking the distribution.