I think your question is perhaps ambiguous (does "typical length of time" mean hours you put in, or days/months from the start of the project?), and not really answerable regardless of the interpretation. There are different kinds of undergraduate research. Here are a couple of the usual ways undergrad research is done:
A somewhat intensive short period of time (6-8 weeks, say) where a student works on a topic chosen by an advisor ahead of time. Presumably these topics are carefully chosen so that the student is able to make real progress in such a short period of time. These projects are often in the form of an REU (Research Experience for Undergraduates). If you do some googling, you will likely find REU's in your field of study, and some advisors/organizers nicely list all of the publications that come out of the REU's. You will see that not all REU projects result in publications.
Working over a longer period of time with a specific professor in your department. This can be an actual job, where you are paid to work in a research lab, or it can be an "independent study" course, where you actually get a couple of credits to work with a professor on a research project. If you are being paid to do research as a student job, your hours may be (at least technically) limited by university policy. This type of research can be very substantial. For example, I knew a person who worked in a professor's fluid mechanics lab for all 4 years of his undergraduate education, and I think they produced and published some nice results.
So, for shorter more packaged projects, I think a "typical" time would be 6-8 weeks. For longer, more open-ended projects, you could potentially work with a professor for years (depending on lab space, grant money, etc.). All of this is highly field-dependent I'm sure.
Now, all of this being said, I think the most important point to make is that publications should not be your ultimate goal. Work hard, be passionate about your field of study, learn as much as you can, and keep up on the other things you have to do as an undergrad. If you do this, then you will impress your advisors and have great letters of recommendation, which will help you get into a great graduate school, and then you can spend the rest of your career worrying about publications :)