Stored in an airtight container, in a cool, dry place, spices retain their potency longer than you'd think — as long as 4 years for whole spices, 2 to 3 years for ground spices, and 1 to 3 years for leafy herbs, depending on the herb.
Whole peppercorns, nutmegs and cinnamon sticks hold on to their flavor for ages. Particularly potent whole spices, such as cloves, cumin, and cardamom will also last for a long, long time.
Herbs lose their flavor faster than spices. Dried herbs that have no color and no or very little smell when crumbled in the palm of your hand are probably too old for practical use. Yet even if they don't look all that green anymore, but still have some oomph when crumbled in your hand, use them freely.
For ground spices, shake the jar, let it settle, and give a sniff. If there's essentially no smell, it should be tossed out. If the spices have a bit of fragrance left but are not as potent as you remember or think they should be, just use more in the recipe. Then you'll run out sooner and have a reason to start fresh with a new batch.(Source)