How long does it take to develop a healthy habit?

Answer: The new habit is engrained when it becomes your default behaviour under stress.  

Explanation:  Underneath each bad habit is faulty perception guiding the behaviour.  Without sufficient time or energy to process the associated emotional charge that guides the negative behaviour, the habit will only last so long as it is not tested under stress.  Once stress elevates beyond what is manageable for the individual then default behaviours will come back. To say the new habit will form in only three weeks or three months creates an expectation that ignores the emotional processing component.  The time it will take is different for everyone. 

Mindful Fix: Rephrase the question from how long does it take to build a healthy habit to: how can I incorporate the desired behaviour into my way of being?  Approaching it from this perspective will set you on a path with higher probabilities of success.  Focus on building awareness of how negative behaviours manifest under stress and how you can navigate that on a moment-to-moment basis. The key is to be very in tune with minute fluctuations of mind/body stress to give the new behaviour a chance to be successful.  Repetition of small successes over time builds a new program in the mind that overrides the old one. It is best to think long term when considering behavioural changes.