CBlock block; uint32_t timestamp = block.GetBlockTime();
CBlockIndex* blockIndex = pindexBest; while (blockIndex) { CBlock block; block.ReadFromDisk(blockIndex); uint32_t timestamp = block.GetBlockTime(); // Do something with the timestamp blockIndex = blockIndex->pprev; }This example iterates through all blocks in the blockchain, starting with the best block (pindexBest). For each block, it reads the block from disk into an instance of the CBlock class, and then calls GetBlockTime to get the timestamp of the block. The timestamp is stored in a variable called "timestamp," and then the code does something with it (not shown). Finally, the code moves on to the previous block using blockIndex->pprev. Package library: Bitcoin Core.