1

Solidity has special keywords now to return current timestamp. solidity documentation on Globally available variables.

uint timestamp = now; //should return current date.

With the help of Ethereum Date and Time tools contract I can obtain followings:

getYear(uint timestamp) constant returns (uint16)  //Given a unix timestamp, returns the DateTime.year value for the timestamp.

getMonth(uint timestamp) constant returns (uint16) //Given a unix timestamp, returns the DateTime.month value for the timestamp.

getDay(uint timestamp) constant returns (uint16)   //Given a unix timestamp, returns the DateTime.day value for the timestamp.

getHour(uint timestamp) constant returns (uint16)  //Given a unix timestamp, returns the DateTime.hour value for the timestamp.

getMinute(uint timestamp) constant returns (uint16) //Given a unix timestamp, returns the DateTime.minute value for the timestamp.

getSecond(uint timestamp) constant returns (uint16) //Given a unix timestamp, returns the DateTime.second value for the timestamp.

I am working on my private ethereum network. The problem is only the returned hour is 2 hours behind than my server's time. I have used following answer's (https://ethereum.stackexchange.com/a/9790/4575) guide to update my server's time.

sudo ntpdate -s time.nist.gov

Also on populus, returned date is wrong for all variables such as year returned 2014 (it should be 2017), month returned as 9 (it should be 1), day returned as 17 (it should be 7) and so on.

[Q] How could I update private blockchain's date that timestamp should updated with an accurate time?

Thank you for your valuable time and help.

alper
  • 8,395
  • 11
  • 63
  • 152

0 Answers0