Each block has a UTC (Standard time) time associated with it called a timestamp. The timestamp is considered valid if it is greater than the median timestamp of the previous 11 blocks and less than the network-adjusted time plus two hours.
Whenever a node connects to another node it gets a UTC timestamp from it.
The timestamp is used whenever any other process, such as Timelocks, needs to know what time a given block was created or how it relates to other blocks.
- Timestamp – Bitcoin Wiki