I'm going to be applying for a Master's program at the end of this year. The problem is that I need a recommendation letter from my professor who would know me only for 4-6 months. Does that make the letter less credible? I don't want my application to be dismissed on the grounds that the professor doesn't know me very well. For additional info, I will be sending in my application to universities in the US and the UK. How do admission officers look at that?
The problem is that I need a recommendation letter from my professor who would know me only for 4-6 months. Does that make the letter less credible?
Less credible than what?
A letter from someone who doesn't know you as well isn't less credible, but it may be less substantive. As @jakebeal says, a professor who knows you longer can write a more substantial letter, all else being equal, simply because they've had time to do more things with you. Credibility is more a function of the reputation and experience of the letter-writer. (Are they successful researchers? Do they know the field well? Do they have past experience with students or the caliber your program is looking for?)
But these comparisons only makes sense if you are choosing between two potential references, one of whom knows you longer than the other. I don't think that's your current dilemma.
You should collect the strongest recommendations you can. If the strongest recommendations you can find come from professors that you only know for a few months, then that is what you should submit. Whether some other hypothetical letters might be stronger is irrelevant—you go to war with the army you have.
I don't want my application to be dismissed on the grounds that the professor doesn't know me very well.
It won't be.
Most graduate programs in the US require multiple recommendation letters, but very few undergraduates have the opportunity, ability, or interest to work directly with multiple faculty for multiple years. So not surprisingly, a significant majority of recommendation letters are written by faculty who only know the applicants for a few months. In particular, most of the graduate-school recommendation letters I've written are for students I'd only known for a few months. This is normal and expected.
What really matters is the substance of the letter, not the duration of your relationship with the writer.
The key property here is not length of time known but strength of what the professor can say about you.
A professor with a longer relationship is likely to have more good things to say simply because they have had time to do more things with you. But if you just have spent a semester doing excellent work with a professor, that is hardly a problem.
Furthermore, a common story for undergraduate students is a "rising trend" as a student gets their life and goals sorted out and only really starts to shine as they come toward the end of their studies. If a professor can contribute to that narrative, that is likely to be a good thing for you rather than bad.