Weeks to months... Depending on what part of the nail is injured as well as its severity. If the bruising is mild, it may heal quickly. If the injury is more severe such that it is causing damage to the nail bed or forming a "blood-clot" from bleeding into the area, it may take however long it is for your nail to grow to the tip/edge of your toe/finger. It is faster for a finger nail to grow comparing to toenail.
Subungual hematoma. When you walk or run wearing tight shoes, your toenail would be hit repeatedly to the edge of the shoe. The blood vessels under the toenail break and cause bleeding under the toenail. This is also known as subungual hematoma. Due to accumulated blood, the nail can turn black and fall off automatically with a new toenail growth. Avoid forced removal. See a doc for pain, redness, swelling or pus.