A transaction doesn't have a timestamp. However, every block provides a timestamp (when it was collected), but if the time is critical for you, don't refer to this timestamp
because a miner could modify it by about 900s. Instead, you could use block.number
.
1- current block timestamp is returned by now
:
e.g.
contract Test {
function Time_call() returns (uint256){
return now;
}
}
Time_call()
will return something like 1478431966
(which you could convert into a readable form in https://www.unixtimestamp.com/).
2- block number is returned using block.number
:
function Time_call() returns (uint256){
return block.number;
}
to get the call time, you could use the block.number
and the block time (an average).
Edit: if you want when the transaction was sent, use JavaScript in your Dapp to get the current time var seconds = new Date().getTime() / 1000;;
and send it in the data field within your transaction.