# Can a miner set the EXACT timestamp of a block?

I know that miners can adjust the timestamp of a block, but can they control the exact timestamp datetime (within the +-2h rule)?

For example:
A miner mines a block at `2013-08-08 08:01:34`.
Can the miner change the block timestamp to `2013-08-08 08:08:08`?

• In theory this is certainly possible - but they have the decide what timestamp they want before starting to mine. Is your question about theory or practice? Aug 7, 2013 at 21:13
• So the answer is yes --- For my question this is theory only. This doesn't really affect bitcoin but the coins that are using a moving average to calculate the difficulty. If the moving average is short enough and a miner have majority of hash power the miner could create a chain of blocks with 0s timestamp apart and mess up the difficulty. --- very unlikely though. Aug 7, 2013 at 22:08
• And also this means that you can not use the block timestamp as a random time function. -- thank you Pieter for you answer. Aug 7, 2013 at 22:17

Bitcoin miners can construct the block header, including the timestamp, however they want, as long as it adheres to the consensus rules. The shift you describe is well inside the 2 hour timerange, so it can be done when setting out to mine the block. It cannot however be done once the block is mined as the timestamp is part of the header, which is hashed into the PoW, hence changing the timestamp would invalidate the proof of work.

Most miners however prefer to increase/decrease the timestamp in order to have a simple way to alter the header, thus more hashes to compute. This is sometimes called time-rolling and is performed on top of the nonce-rolling.

• Your answer might be confusing, as the asker seems to propose to change the timestamp after a block is found. You might want to clarify that this is not possible (although, I think I have been clear on that in my answer).
– Murch
Jun 25, 2015 at 8:31
• Thanks for the correction, I must have missed the fact that he is asking for a posteriori modifications of a block. Jun 25, 2015 at 8:53

The timestamp is part of the input for the mining process.

So, the miner can set an arbitrary timestamp, but must decide before hashing what timestamp he wants a potential block to have.

He cannot change the timestamp after finding a block, because the timestamp is part of the block, and a different one wouldn't be valid. To change the timestamp, he would have to start over mining.