You have to code it into your contract either by saving the block.timestamp in the constructor:
contract A {
uint public createdTimestamp;
function A() {
createdTimestamp = block.timestamp;
}
}
which you can access like this:
contract B is Test {
function testTimestamp () {
A a = new A();
uint timestamp = a.createdTimestamp();
//@log timestamp `uint timestamp`
}
}
or log an event, if you don't need to access this information from within the chain:
contract A {
event created(uint timestamp);
function A() {
created(block.timestamp);
}
}
But a query for arbitrary contracts is not possible, however this can be achieved in O(log_2 n) with a binary search for contract code.