1. The original due date for the return must be at least three years prior to the filing date of the bankruptcy. In other words, taxes originally due April 15, 2014 (which would be the 2013 tax year) could be discharged by a bankruptcy filed April 16, 2017 or later if the following criteria are also met. 11 U.S.C. 507(a)(8).
2. You must have actually filed the tax return at least two years prior to the filing date of the bankruptcy. This means you can discharge taxes even if you filed the return late. For instance, if you did not file the return originally due on April 15, 2014 until April 15, 2015, you could still discharge those taxes in a bankruptcy filed April 16, 2017 or later. 11 U.S.C. 523(a)(1).
3. Finally, if the IRS has assessed your taxes, you can only discharge the tax obligation if that assessment was done at least 240 days before the filing date of your bankruptcy. If you the IRS has not assessed your taxes at all (and you meet the first two criteria) you can still discharge those taxes. 11 U.S.C. 507(a)(8)
As with everything, there can be exceptions to the rule. If you're unsure whether you can discharge your income tax obligations, talk to an experienced bankruptcy lawyer.