Here is an article on how to make comparisons using clock.unix_timestampps" and time provided by
instructionis.arg”:
Comparison of the UNIX TimesTamp in force
When creating public opinion searches or candidates are started, it is necessary to make sure that they start before adding the candidate. However, if there are problems with the times, it could be a challenge to determine that the research on public opinion has begun correctly.
In this article, we examine how to compare the time provided by Clock.unix_timestamps" and from the topics "instructions".
What is the UNIX TimesTamp?
Unix TimesTamp is a number that represents the number of seconds from 1 January 1970, at 00:00:00. It is possible to obtain the Date.NOW () or the "Unixtimestamp ()" method on an object from date.
Hour.unix_timestamps in Fork
In case of strength, it is possible to obtain the current UNIX TimesTamp using the following syntax:
Solidity
Const UniXTimestamp = date.NOW () / 1000;
This returns an integer that represents the number of seconds from 1 January 1970, 00:00:00 Street.
To compare UNIX
Timestamp
You can use the following features to compare two UNIX TimesTamp:
Clock.unix_timestamps ((solidity 0.6.x and subsequently)
Solidity
Const UniXtumesamp1 = Clorch.unix_timestamps ();
Const UniXtumesamp2 = Instructions.arg (0) .unxtimestamp ();
IF (UniXTimestamp1
// Public research has started
} Else If (UniXTimestamp1> Unixtimestamp2) {
// Public research has not started correctly
} Other {
// Both votes started at the same time
}
Clock.unix_timestampps (0)
(solidity 0.4.x and before)
`Solidity
Const UniXtumesamp1 = Clock.unix_timestamps (0);
Const UniXtumesamp2 = Instructions.arg (0) .unxtimestamp ();
IF (UniXTimestamp1
// Public research has started
} Else If (UniXTimestamp1> Unixtimestamp2) {
// Public research has not started correctly
} Other {
// Both votes started at the same time
}
** UsingInstructions.arg (0) .unixtimeestamp () Using
Alternatively, it is possible to use instructions.arg (0) .unixtimestamp ()
to obtain the TimesTamp of the UNIX of the vote instructions. This is useful if it is necessary to compare it with a fixed time.
For example:
Solidity
Const UniXtumesamp1 = Instructions.arg (0) .unixtumesppap ();
Const UniXtumesamp2 = Clorch.unix_timestamps ();
IF (UniXTimestamp1
// Public research has started
} Else If (UniXTimestamp1> Unixtimestamp2) {
// Public research has not started correctly
} Other {
// Both votes started at the same time
}
Conclusion
In summary, compared to "Clock.unix_timestamps" and "Instructions provided by instructions.arg (0) .uxtimestamp () The topics of force are clear. Using one of these functions, it is possible to guarantee that the research on public opinion is started correctly and that candidates will begin if necessary.
I hope this helps! Tell me if you have further questions or you need further help.