Currently visa exempt provides 60 day stamp.
Most offices require min 15 days remaining.
CM require 21. Phuket 15 working days.
Most offices allow you to apply 30 days prior to expiry.
Some eg CM, CW etc 45 days prior
Which immigration office do you deal with.
I asked earlier for a reason