How Bitcoin Difficulty Gets Adjusted
Bitcoin difficulty increases exponentially over time. Source: BitcoinWisdom
Technology advances exponentially, and with it, the rate of computation speed of the Bitcoin network increases. There is also the unpredictability of the size and state of the network in any future point in time. Although new miners join constantly, physical factors, such as power and network outages, may temporarily or permanently reduce the size of the Bitcoin network, leaving the generation of new bitcoins to the rest.
To account for this, the Bitcoin algorithm has a built-in concept of "difficulty", which increases or decreases regularly, to account for possible changes in the network's computational rate. After each 2016 new blocks have been inserted into the block chain, there is a readjustment. The number 2016 is arbitrary and accounts for a readjustment every 2 weeks, assuming that the 10-minute rate per inserting a new block is kept intact (10624*14 = 2016).
Bitcoin difficulty is calculated using a complex formula, but roughly, it corresponds to the number of trailing zeroes at the beginning of a valid hash. The bigger the difficulty, the more the zeroes, and correspondingly, the more then iterations that a machine must go through, in order to find a valid hash.
Bitcoin difficulty is carried in the header of each block, and used as part of the ingredients of of the hash. As the entire block chain is equally accessible to all the mining nodes in the network, it is guaranteed that all of them would equally adjust the difficulty in the subsequent blocks they compute, without having to agree on it. If a node tries to insert a new block with difficulty less than the one expected by everyone else (trying to game the system), the block will be deemed invalid and rejected by peer nodes.
The difficulty value gets carried in the header of each block, under the name of "bits". Source: Ken Schirriff
Calculate the estimated time to mining: http://www.wolframalpha.com/widgets/gallery/view.jsp?id=76444b3132fda0e2aca778051d776f1c