For HDB with extension, either way HDB would be charged a minimum of 3 months, whether it is earlier or later. This is subject to private agreement, but most arrangements are for 3 months. The extension arrangement would have to be discussed during the negotiation period and would have to be included during the HDB resale application process.
Be sure to always discuss this with your agent and make sure that the seller side is agreeable to cover the relevant fees during the period of extensions. Examples of such fees would be the conveyance charges, utility bills, and non-occupier property tax.