What is the origin of the phrase In the nick of time?

Around the 1580's the phrase in the nick meant in the cut or notch to mean at a precise moment in time. The phrase evolved to be in the nick of time. Nowadays the meaning has also evolved to mean at the last moment.
At the last second. Example: I was begging to starve but in the nick of time, the pizza man delivered our food.