Our Gemara on Amud Aleph discusses that the standard amount of days for an unspecified Nezirus is 30.  The Gemara (5a) sees a hint to this from the Gematria numeric of the Hebrew word “Yihyeh”, “He shall be a holy” in Number 6:5, which equals 30.

Why does the Torah not make this number explicit? The Meshech Chokhma explains that the Torah leaves it vague because each person must make their own evaluation of what is necessary to dampen his or her excessive materialism, which is the function of the Nazirite abstentions.  

Chovos Halevavos (Shaar Hayichud 10) comments similarly, but not specifically in regard to the Nazir: 

וכן נאמר בבאור החכמה הצפונה אשר כווננו לבארה בספר הזה כי התורה קצרה בבאור ענינה מפני שסמכה בו על השכל ורמזה ממנה ברמזים להעיר עליהם כבר זכרנום בתחלת הספר הזה להתעורר אליה כל מי שיוכל לחקור עליה ולדרוש אותה כדי שיגיע אליה ויבינה כמ״‎ש (משלי כח) ומבקשי ה׳ ‎‎יבינו כל.

And likewise we will say for the clarification of the inner wisdom (the duties of the heart) which was our intention to clarify in this book. The Torah was very brief in expounding their matters, relying on the intelligent men. The Torah only hinted at it to arouse one on it, such as mentioned in the Introduction of this book, so that anyone who is able to enquire and investigate them will be aroused to do so until he has understood and mastered them as written: "those who seek G-d will understand all things" (Mishlei 28:5).

The Rama (Toras HaOlah 3:71) adds that 30 days is typical amount of time to change a trait, perhaps this is reflected in that 29-30 days is the length of month, representing section of time in a person’s life.  He also notes that the Gematria derash of 30 is from the word “Yihyeh”, which means “to become”.  This is because the 30 days of abstention is an effort to become something.

In terms of current psychological research, the amount of time it takes to achieve a habit varies greatly, but definitely relies on consistent repetition. In one study (source below), the average time for habit formation was about 66 days, but of course there can be tremendous variability. Other factors to consider are the complexity of the habit, and the relative rewards of new practice versus the desire to remain with the gratifications of the prior practice. A habit for brushing teeth, as compared to a habit such as refraining from eating junk food, have different incentives as well require a different degree of mindfulness to encourage inhibition. In order to change states of mind and emotional orientation, such as generosity or hedonistic behaviors and desires, one must summon more sophisticated levels of effort and focus. This is not only because of its subtlety, but also due to its unpredictability. A person brushes and flosses twice a day, and eats three times a day, often a specific times and locations. These factors act as reinforcing cues. However, an opportunity to enact a character trait,  such as patience or forgiveness, can occur several times a day or once a week. This makes it more challenging to habitualize. 

Rav Yisrael Salanter famously said, “It is easier to learn the entire Shas than to change one middah.”

For more about habit formation, see European Journal of Social Psychology Eur. J. Soc. Psychol. 40, 998–1009 (2010) Published online 16 July 2009 in Wiley Online Library (wileyonlinelibrary.com) DOI: 10.1002/ejsp.674 Abstract Research article How are habits formed: Modelling habit formation in the real worldy PHILLIPPA LALLY*, CORNELIA H. M. VAN JAARSVELD, HENRY W. W. POTTS AND JANE WARDLE University College London, London, UK.)