thanks for taking the time to read this.
I'm having a bit of trouble handling time in Solidity. I want the owner of a contract to be able to set a deadline in days (which will be used in the rest of the contract) on the constructor. I wrote this:
constructor(uint _price, uint _days) public {
owner = msg.sender;
price = _price;
deadlineInDays = now + _days;
}
But as you may be aware, when the owner inputs any value in _days, it is added to the Epoch Time format (now). So, for example, if I set it to "10", when I call this function to return it:
function getPriceAndDeadline() public view returns (uint _price, uint _deadline)
{
return (price, deadlineInDays);
}
It returns something like this:
_price 1000
_deadline 1544005222 // this is only ten seconds after I ran the constructor
I obviously wanted it to return whatever "now" is plus "_days" in days, not in seconds.
I tried this (below), but it doesn't work.
constructor(uint _price, uint _days) public {
owner = msg.sender;
price = _price;
deadlineInDays = now + _days days;
}
Any ideas on how to handle this?
I appreciate any inputs in advance! Cheers!