A friend asked for my advice on this subject recently:
I’m kind of thinking about changing jobs. I’m doing good at [COMPANY] so no concerns there. I would honestly rather be working in the software and technology space, instead of the financial industry. […] The other factor is that I’m not in an area where I can attend conferences and be involved in a good development community. I’ve only been at [COMPANY] for [less than 12] months. What do you think?
While I was flattered to be asked for such personal advice, I’m not really qualified to say what’s best for anyone. Maybe not even myself. Remember this.
The following is the philosophy that I try to follow in terms of changing jobs in case helps anyone.
When To Leave
First, as anyone I’ve talked with about this will tell you, I’m a big proponent of changing jobs at least every 3-4 years.
In our profession, this helps us remain fresh and exposes us to new tech/architectures/ideas in a way that is hard to ignore. This is a good thing. My general rule holds unless there are special circumstances. For example: vesting concerns, when nearing retirement, or another important life event. I’ll also interview every year or two in order to keep my interviewee skills honed and because it helps me to be a better interviewer when I’m performing interviews at my current company.
When To Stay
As for a shorter end of the tenure spectrum, I usually will stay a minimum of 1-2 years.
Again, this is a rule of thumb. I’m not going to cover all of the exceptions here. If circumstances like a hostile work environment or an amazing new opportunity came up, I would consider breaking it. I have a friend who left a company after a couple months once because it ended up being hostile. I can’t imagine any decent future employer who would fault him for this. However, it is the only instance like this in his career. An established pattern of “hostile” work environments is a read flag all by itself.
If you are making an immediate decision, sleep on it. One more night can help organize your thoughts and shouldn’t hurt anyone involved.

As for my recommendations, the first year is basically for resume purposes… taking a full-time employee position and then quitting before a year is up might make some employers question the value of going through the cost and effort of bringing you on. It may even be “interview prohibitive”.
The second year and beyond is often when I find that I learn the most about a business, can contribute the most (due to knowledge, trust/influence earned). It is also when I solidify relationships with people I work with.
Contracts
All of this is basically thrown out the window for contract positions. Contractors are expected to be mercenaries, to an extent, and might switch companies/projects every month without much scrutiny. I think there are some interesting things to be learned from that as well but I don’t have a lot of personal experience. I’ve considered joining a firm similar to Catapult or StG that sends contractors out to multiple companies and has a bench program for downtime. I believe it would be a valuable experience.
Summary
So the short version is: except for contracts, aim for a 1-4 year stay whenever starting a new job. Commit to this mentally, or don’t accept the offer. An exception could definitely be made in either direction under the right circumstances, but don’t plan on it. In practice, I have stayed at each of my gigs for 2-3 years without exception.
In my friend’s case, his company/team doesn’t match the values he wished they had and isn’t working on anything terribly interesting. Also, he is considering leaving the area. Not an emergency per se, but not great either.
My advice to him was to stick it out until a year is up while doing his best to influence change at the company. If things don’t start to improve in that time-frame, (i.e. if he felt he wasn’t having a positive impact) start looking.
Again, I’m not really qualified to advise anyone on their particular situation. I do believe these ideas have value and should be discussed.