Most immigration offices you can apply for an extension 30 days before your stay expires, Bangkok, Phuket, and Chiang Mai is 45 days. The extension is added to your expiration date, doesn't matter when you go.
Also just to add, the 30 day extensions are added to the time you're currently stamped in for, so 30 day from Jan 17th reguardless of when you apply for it so there's no benefit of waiting until the last day.