If the dust was really on the sensor proper, you'd be absolutely correct.

At least in the normal case, it's virtually impossible for dust to get on the surface of the sensor itself, because there's a couple millimeters or so of filters directly in front of the sensor. The front-most of these is (at least in the usual case) the AA filer.

The important thing is that all of this transparent glass. Therefore, with a wider aperture, there's more light coming at the sensor from various angles. Since the light can travel at whatever angle through those filters (because they're all at least mostly-transparent glass), the dust spots won't normally block all the light. With a smaller aperture, the light comes nearly straight back from the small aperture, so the edges of any dust spots are clearly defined.

In practice, the difference is pretty obvious. Here's a shot at f/1.7, then shot taken a few moments later at f/22 (same camera, same lens, etc. -- all that's changed is the aperture and shutter speed):

f/1.7:


f/22:


Like usual for this situation, I've also boosted the contrast to make the dust more visible -- since it's a plain, low-contrast subject, the histogram starts out like this:



To make the dust more apparent, you adjust the levels something like this:



If you apply it to the f/1.7 picture (as I did above, to keep things fair), that will also overemphasize the light falloff at the corners of the picture. Though there is some anyway, it's not normally even close to as bad as it looks in the first shot above.

Note that this is a pretty rigorous test. This sensor is clean enough that on typical shots, there's no sign of dust on the sensor at all. Between the total lack of contrast/detail in the subject, tiny aperture, and extreme boost of contrast, we're seeing quite a bit that we'd never see in any normal picture (not to mention that the two worst spots here are near the bottom of the frame, where there's nearly always at least a little detail to hide these problems anyway). If you test this on your own camera, don't be too surprised if it looks (quite possibly a lot) worse than the ones above. From what I've seen, I'd guess that most dSLRs (and a pretty fair number of P&amp;S cameras too) are at least a little, and often a lot, worse than this.

Why use a small aperture when trying to see sensor dust?
I'm using Bootstrap datepicker and I'd like to make that when datepicker shows, default date would be set after 14 days from today. I've got this code but it doesn't work, default date is still set to today. Could anyone explain what am I missing? Thanks in advance. 

JS:

  var plus14days = new Date();

  plus14days.setDate(plus14days.getDate() + 14 );
  $(".datepicker").datepicker("setValue", plus14days);

