Skip to main content
4 of 6
added 73 characters in body
Badr Bellaj
  • 18.8k
  • 4
  • 59
  • 75

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 you could use instead block.number.

1- current block timestamp is returned by now :

e.g

contract Test {
    function Time_call() returns (uint256){
        return now;
    }
}

Time_call will returns something like : 1478431966 (which you could convert in a readble form in http://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 avarage)

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 withing your transaction.

Badr Bellaj
  • 18.8k
  • 4
  • 59
  • 75