I recently submitted my phd thesis and immediately joined as a faculty member in another institute. My final phd viva will be in around 3 months time. Now, I need to publish some of my thesis work which I haven't published yet. Do I need to give my affiliation from both my institutes? Can I give both?? I will be the corresponding author.
I had the same thing recently and was advised to include both if you have used any resources (including time) while working at the new institute on the paper. I chatted with my advisor at the new institute and we agreed that as any work I had done on my PhD paper was done in my spare time, not during time my new institute was paying me for, I didn't need to include them as an affiliation.
But if you're taking significant chunks of the working day to work on this paper (including during review response) and the institute is paying you for that time, I would include them, as they have then been funding the time you're spending to work on it. Also in my case, I totally switched fields to one my new institute doesn't do any work in so they didn't really want their name on my old work.
How you list your affiliation is field dependent. You could probably ask your advisor what is best for you. I assume you can list them both.
See this answer to a meta post for part of the discussion on variability in academia.
If your doctoral institution funded you in any way they probably want an acknowledgement, at least. Maybe so even when they don't. But your readers will also want to be able to find you if they have questions, etc.